1 /* Font backend for the Microsoft Windows API.
2 Copyright (C) 2007-2015 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
60 static void fill_in_logfont (struct frame
*, LOGFONT
*, Lisp_Object
);
62 static BYTE
w32_antialias_type (Lisp_Object
);
63 static Lisp_Object
lispy_antialias_type (BYTE
);
65 static Lisp_Object
font_supported_scripts (FONTSIGNATURE
*);
66 static int w32font_full_name (LOGFONT
*, Lisp_Object
, int, char *, int);
67 static void compute_metrics (HDC
, struct w32font_info
*, unsigned int,
68 struct w32_metric_cache
*);
70 static Lisp_Object
w32_registry (LONG
, DWORD
);
72 /* EnumFontFamiliesEx callbacks. */
73 static int CALLBACK ALIGN_STACK
add_font_entity_to_list (ENUMLOGFONTEX
*,
76 static int CALLBACK ALIGN_STACK
add_one_font_entity_to_list (ENUMLOGFONTEX
*,
79 static int CALLBACK ALIGN_STACK
add_font_name_to_list (ENUMLOGFONTEX
*,
83 /* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
84 of what we really want. */
85 struct font_callback_data
87 /* The logfont we are matching against. EnumFontFamiliesEx only matches
88 face name and charset, so we need to manually match everything else
89 in the callback function. */
91 /* The original font spec or entity. */
92 Lisp_Object orig_font_spec
;
93 /* The frame the font is being loaded on. */
95 /* The list to add matches to. */
97 /* Whether to match only opentype fonts. */
101 /* Handles the problem that EnumFontFamiliesEx will not return all
102 style variations if the font name is not specified. */
103 static void list_all_matching_fonts (struct font_callback_data
*);
107 static BOOL g_b_init_get_outline_metrics_w
;
108 static BOOL g_b_init_get_text_metrics_w
;
109 static BOOL g_b_init_get_glyph_outline_w
;
110 static BOOL g_b_init_get_glyph_outline_w
;
111 static BOOL g_b_init_get_char_width_32_w
;
113 typedef UINT (WINAPI
* GetOutlineTextMetricsW_Proc
) (
116 LPOUTLINETEXTMETRICW lpotmw
);
117 typedef BOOL (WINAPI
* GetTextMetricsW_Proc
) (
119 LPTEXTMETRICW lptmw
);
120 typedef DWORD (WINAPI
* GetGlyphOutlineW_Proc
) (
128 typedef BOOL (WINAPI
* GetCharWidth32W_Proc
) (
134 /* Several "wide" functions we use to support the font backends are
135 unavailable on Windows 9X, unless UNICOWS.DLL is installed (their
136 versions in the default libraries are non-functional stubs). On NT
137 and later systems, these functions are in GDI32.DLL. The following
138 helper function attempts to load UNICOWS.DLL on Windows 9X, and
139 refuses to let Emacs start up if that library is not found. On NT
140 and later versions, it simply loads GDI32.DLL, which should always
143 w32_load_unicows_or_gdi32 (void)
145 return maybe_load_unicows_dll ();
148 /* The following 3 functions call the problematic "wide" APIs via
149 function pointers, to avoid linking against the non-standard
150 libunicows on W9X. */
152 get_outline_metrics_w(HDC hdc
, UINT cbData
, LPOUTLINETEXTMETRICW lpotmw
)
154 static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW
= NULL
;
155 HMODULE hm_unicows
= NULL
;
156 if (g_b_init_get_outline_metrics_w
== 0)
158 g_b_init_get_outline_metrics_w
= 1;
159 hm_unicows
= w32_load_unicows_or_gdi32 ();
161 s_pfn_Get_Outline_Text_MetricsW
= (GetOutlineTextMetricsW_Proc
)
162 GetProcAddress (hm_unicows
, "GetOutlineTextMetricsW");
164 eassert (s_pfn_Get_Outline_Text_MetricsW
!= NULL
);
165 return s_pfn_Get_Outline_Text_MetricsW (hdc
, cbData
, lpotmw
);
169 get_text_metrics_w(HDC hdc
, LPTEXTMETRICW lptmw
)
171 static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW
= NULL
;
172 HMODULE hm_unicows
= NULL
;
173 if (g_b_init_get_text_metrics_w
== 0)
175 g_b_init_get_text_metrics_w
= 1;
176 hm_unicows
= w32_load_unicows_or_gdi32 ();
178 s_pfn_Get_Text_MetricsW
= (GetTextMetricsW_Proc
)
179 GetProcAddress (hm_unicows
, "GetTextMetricsW");
181 eassert (s_pfn_Get_Text_MetricsW
!= NULL
);
182 return s_pfn_Get_Text_MetricsW (hdc
, lptmw
);
186 get_glyph_outline_w (HDC hdc
, UINT uChar
, UINT uFormat
, LPGLYPHMETRICS lpgm
,
187 DWORD cbBuffer
, LPVOID lpvBuffer
, const MAT2
*lpmat2
)
189 static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW
= NULL
;
190 HMODULE hm_unicows
= NULL
;
191 if (g_b_init_get_glyph_outline_w
== 0)
193 g_b_init_get_glyph_outline_w
= 1;
194 hm_unicows
= w32_load_unicows_or_gdi32 ();
196 s_pfn_Get_Glyph_OutlineW
= (GetGlyphOutlineW_Proc
)
197 GetProcAddress (hm_unicows
, "GetGlyphOutlineW");
199 eassert (s_pfn_Get_Glyph_OutlineW
!= NULL
);
200 return s_pfn_Get_Glyph_OutlineW (hdc
, uChar
, uFormat
, lpgm
, cbBuffer
,
205 get_char_width_32_w (HDC hdc
, UINT uFirstChar
, UINT uLastChar
, LPINT lpBuffer
)
207 static GetCharWidth32W_Proc s_pfn_Get_Char_Width_32W
= NULL
;
208 HMODULE hm_unicows
= NULL
;
209 if (g_b_init_get_char_width_32_w
== 0)
211 g_b_init_get_char_width_32_w
= 1;
212 hm_unicows
= w32_load_unicows_or_gdi32 ();
214 s_pfn_Get_Char_Width_32W
= (GetCharWidth32W_Proc
)
215 GetProcAddress (hm_unicows
, "GetCharWidth32W");
217 eassert (s_pfn_Get_Char_Width_32W
!= NULL
);
218 return s_pfn_Get_Char_Width_32W (hdc
, uFirstChar
, uLastChar
, lpBuffer
);
223 /* Cygwin doesn't support Windows 9X, and links against GDI32.DLL, so
224 it can just call these functions directly. */
225 #define get_outline_metrics_w(h,d,o) GetOutlineTextMetricsW(h,d,o)
226 #define get_text_metrics_w(h,t) GetTextMetricsW(h,t)
227 #define get_glyph_outline_w(h,uc,f,gm,b,v,m) \
228 GetGlyphOutlineW(h,uc,f,gm,b,v,m)
229 #define get_char_width_32_w(h,fc,lc,b) GetCharWidth32W(h,fc,lc,b)
234 memq_no_quit (Lisp_Object elt
, Lisp_Object list
)
236 while (CONSP (list
) && ! EQ (XCAR (list
), elt
))
238 return (CONSP (list
));
242 intern_font_name (char * string
)
244 Lisp_Object str
= DECODE_SYSTEM (build_string (string
));
245 ptrdiff_t len
= SCHARS (str
);
246 Lisp_Object obarray
= check_obarray (Vobarray
);
247 Lisp_Object tem
= oblookup (obarray
, SDATA (str
), len
, len
);
248 /* This code is similar to intern function from lread.c. */
249 return SYMBOLP (tem
) ? tem
: intern_driver (str
, obarray
, tem
);
252 /* w32 implementation of get_cache for font backend.
253 Return a cache of font-entities on FRAME. The cache must be a
254 cons whose cdr part is the actual cache area. */
256 w32font_get_cache (struct frame
*f
)
258 struct w32_display_info
*dpyinfo
= FRAME_DISPLAY_INFO (f
);
260 return (dpyinfo
->name_list_element
);
263 /* w32 implementation of list for font backend.
264 List fonts exactly matching with FONT_SPEC on FRAME. The value
265 is a vector of font-entities. This is the sole API that
266 allocates font-entities. */
268 w32font_list (struct frame
*f
, Lisp_Object font_spec
)
270 Lisp_Object fonts
= w32font_list_internal (f
, font_spec
, 0);
271 FONT_ADD_LOG ("w32font-list", font_spec
, fonts
);
275 /* w32 implementation of match for font backend.
276 Return a font entity most closely matching with FONT_SPEC on
277 FRAME. The closeness is determined by the font backend, thus
278 `face-font-selection-order' is ignored here. */
280 w32font_match (struct frame
*f
, Lisp_Object font_spec
)
282 Lisp_Object entity
= w32font_match_internal (f
, font_spec
, 0);
283 FONT_ADD_LOG ("w32font-match", font_spec
, entity
);
287 /* w32 implementation of list_family for font backend.
288 List available families. The value is a list of family names
291 w32font_list_family (struct frame
*f
)
293 Lisp_Object list
= Qnil
;
294 LOGFONT font_match_pattern
;
297 memset (&font_match_pattern
, 0, sizeof (font_match_pattern
));
298 font_match_pattern
.lfCharSet
= DEFAULT_CHARSET
;
300 dc
= get_frame_dc (f
);
302 EnumFontFamiliesEx (dc
, &font_match_pattern
,
303 (FONTENUMPROC
) add_font_name_to_list
,
305 release_frame_dc (f
, dc
);
310 /* w32 implementation of open for font backend.
311 Open a font specified by FONT_ENTITY on frame F.
312 If the font is scalable, open it with PIXEL_SIZE. */
314 w32font_open (struct frame
*f
, Lisp_Object font_entity
, int pixel_size
)
316 Lisp_Object font_object
317 = font_make_object (VECSIZE (struct w32font_info
),
318 font_entity
, pixel_size
);
319 struct w32font_info
*w32_font
320 = (struct w32font_info
*) XFONT_OBJECT (font_object
);
322 ASET (font_object
, FONT_TYPE_INDEX
, Qgdi
);
324 if (!w32font_open_internal (f
, font_entity
, pixel_size
, font_object
))
329 /* GDI backend does not use glyph indices. */
330 w32_font
->glyph_idx
= 0;
335 /* w32 implementation of close for font_backend. */
337 w32font_close (struct font
*font
)
339 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
343 /* Delete the GDI font object. */
344 DeleteObject (w32_font
->hfont
);
345 w32_font
->hfont
= NULL
;
347 /* Free all the cached metrics. */
348 if (w32_font
->cached_metrics
)
352 for (i
= 0; i
< w32_font
->n_cache_blocks
; i
++)
353 xfree (w32_font
->cached_metrics
[i
]);
354 xfree (w32_font
->cached_metrics
);
355 w32_font
->cached_metrics
= NULL
;
360 /* w32 implementation of has_char for font backend.
362 If FONT_ENTITY has a glyph for character C (Unicode code point),
363 return 1. If not, return 0. If a font must be opened to check
366 w32font_has_char (Lisp_Object entity
, int c
)
368 /* We can't be certain about which characters a font will support until
369 we open it. Checking the scripts that the font supports turns out
370 to not be reliable. */
374 Lisp_Object supported_scripts
, extra
, script
;
377 extra
= AREF (entity
, FONT_EXTRA_INDEX
);
381 supported_scripts
= assq_no_quit (QCscript
, extra
);
382 /* If font doesn't claim to support any scripts, then we can't be certain
384 if (!CONSP (supported_scripts
))
387 supported_scripts
= XCDR (supported_scripts
);
389 script
= CHAR_TABLE_REF (Vchar_script_table
, c
);
391 /* If we don't know what script the character is from, then we can't be
392 certain until we open it. Also if the font claims support for the script
393 the character is from, it may only have partial coverage, so we still
394 can't be certain until we open the font. */
395 if (NILP (script
) || memq_no_quit (script
, supported_scripts
))
398 /* Font reports what scripts it supports, and none of them are the script
399 the character is from. But we still can't be certain, as some fonts
400 will contain some/most/all of the characters in that script without
401 claiming support for it. */
406 /* w32 implementation of encode_char for font backend.
407 Return a glyph code of FONT for character C (Unicode code point).
408 If FONT doesn't have such a glyph, return FONT_INVALID_CODE.
410 For speed, the gdi backend uses Unicode (Emacs calls encode_char
411 far too often for it to be efficient). But we still need to detect
412 which characters are not supported by the font.
415 w32font_encode_char (struct font
*font
, int c
)
417 struct w32font_info
* w32_font
= (struct w32font_info
*)font
;
419 if (c
< w32_font
->metrics
.tmFirstChar
420 || c
> w32_font
->metrics
.tmLastChar
)
421 return FONT_INVALID_CODE
;
426 /* w32 implementation of text_extents for font backend.
427 Perform the size computation of glyphs of FONT and fillin members
428 of METRICS. The glyphs are specified by their glyph codes in
429 CODE (length NGLYPHS). Apparently metrics can be NULL, in this
430 case just return the overall width. */
432 w32font_text_extents (struct font
*font
, unsigned *code
,
433 int nglyphs
, struct font_metrics
*metrics
)
436 HFONT old_font
= NULL
;
443 struct w32font_info
*w32_font
= (struct w32font_info
*) font
;
445 memset (metrics
, 0, sizeof (struct font_metrics
));
446 metrics
->ascent
= font
->ascent
;
447 metrics
->descent
= font
->descent
;
449 for (i
= 0; i
< nglyphs
; i
++)
451 struct w32_metric_cache
*char_metric
;
452 int block
= *(code
+ i
) / CACHE_BLOCKSIZE
;
453 int pos_in_block
= *(code
+ i
) % CACHE_BLOCKSIZE
;
455 if (block
>= w32_font
->n_cache_blocks
)
457 if (!w32_font
->cached_metrics
)
458 w32_font
->cached_metrics
459 = xmalloc ((block
+ 1)
460 * sizeof (struct w32_metric_cache
*));
462 w32_font
->cached_metrics
463 = xrealloc (w32_font
->cached_metrics
,
465 * sizeof (struct w32_metric_cache
*));
466 memset (w32_font
->cached_metrics
+ w32_font
->n_cache_blocks
, 0,
467 ((block
+ 1 - w32_font
->n_cache_blocks
)
468 * sizeof (struct w32_metric_cache
*)));
469 w32_font
->n_cache_blocks
= block
+ 1;
472 if (!w32_font
->cached_metrics
[block
])
474 w32_font
->cached_metrics
[block
]
475 = xzalloc (CACHE_BLOCKSIZE
* sizeof (struct w32_metric_cache
));
478 char_metric
= w32_font
->cached_metrics
[block
] + pos_in_block
;
480 if (char_metric
->status
== W32METRIC_NO_ATTEMPT
)
484 /* TODO: Frames can come and go, and their fonts
485 outlive them. So we can't cache the frame in the
486 font structure. Use selected_frame until the API
487 is updated to pass in a frame. */
488 f
= XFRAME (selected_frame
);
490 dc
= get_frame_dc (f
);
491 old_font
= SelectObject (dc
, w32_font
->hfont
);
493 compute_metrics (dc
, w32_font
, *(code
+ i
), char_metric
);
496 if (char_metric
->status
== W32METRIC_SUCCESS
)
498 metrics
->lbearing
= min (metrics
->lbearing
,
499 metrics
->width
+ char_metric
->lbearing
);
500 metrics
->rbearing
= max (metrics
->rbearing
,
501 metrics
->width
+ char_metric
->rbearing
);
502 metrics
->width
+= char_metric
->width
;
505 /* If we couldn't get metrics for a char,
506 use alternative method. */
509 /* If we got through everything, return. */
514 /* Restore state and release DC. */
515 SelectObject (dc
, old_font
);
516 release_frame_dc (f
, dc
);
521 /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
522 fallback on other methods that will at least give some of the metric
525 /* Make array big enough to hold surrogates. */
526 wcode
= alloca (nglyphs
* sizeof (WORD
) * 2);
527 for (i
= 0; i
< nglyphs
; i
++)
529 if (code
[i
] < 0x10000)
533 DWORD surrogate
= code
[i
] - 0x10000;
535 /* High surrogate: U+D800 - U+DBFF. */
536 wcode
[i
++] = 0xD800 + ((surrogate
>> 10) & 0x03FF);
537 /* Low surrogate: U+DC00 - U+DFFF. */
538 wcode
[i
] = 0xDC00 + (surrogate
& 0x03FF);
539 /* An extra glyph. wcode is already double the size of code to
547 /* TODO: Frames can come and go, and their fonts outlive
548 them. So we can't cache the frame in the font structure. Use
549 selected_frame until the API is updated to pass in a
551 f
= XFRAME (selected_frame
);
553 dc
= get_frame_dc (f
);
554 old_font
= SelectObject (dc
, w32_font
->hfont
);
557 if (GetTextExtentPoint32W (dc
, wcode
, nglyphs
, &size
))
559 total_width
= size
.cx
;
562 /* On 95/98/ME, only some Unicode functions are available, so fallback
563 on doing a dummy draw to find the total width. */
567 rect
.top
= 0; rect
.bottom
= font
->height
; rect
.left
= 0; rect
.right
= 1;
568 DrawTextW (dc
, wcode
, nglyphs
, &rect
,
569 DT_CALCRECT
| DT_NOPREFIX
| DT_SINGLELINE
);
570 total_width
= rect
.right
;
573 /* Give our best estimate of the metrics, based on what we know. */
574 metrics
->width
= total_width
- w32_font
->metrics
.tmOverhang
;
575 metrics
->lbearing
= 0;
576 metrics
->rbearing
= total_width
;
578 /* Restore state and release DC. */
579 SelectObject (dc
, old_font
);
580 release_frame_dc (f
, dc
);
583 /* w32 implementation of draw for font backend.
585 Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
586 position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
587 fill the background in advance. It is assured that WITH_BACKGROUND
588 is false when (FROM > 0 || TO < S->nchars).
590 TODO: Currently this assumes that the colors and fonts are already
591 set in the DC. This seems to be true now, but maybe only due to
592 the old font code setting it up. It may be safer to resolve faces
593 and fonts in here and set them explicitly
597 w32font_draw (struct glyph_string
*s
, int from
, int to
,
598 int x
, int y
, bool with_background
)
601 HRGN orig_clip
= NULL
;
603 struct w32font_info
*w32font
= (struct w32font_info
*) s
->font
;
605 options
= w32font
->glyph_idx
;
607 if (s
->num_clips
> 0)
609 HRGN new_clip
= CreateRectRgnIndirect (s
->clip
);
611 /* Save clip region for later restoration. */
612 orig_clip
= CreateRectRgn (0, 0, 0, 0);
613 if (!GetClipRgn (s
->hdc
, orig_clip
))
615 DeleteObject (orig_clip
);
619 if (s
->num_clips
> 1)
621 HRGN clip2
= CreateRectRgnIndirect (s
->clip
+ 1);
623 CombineRgn (new_clip
, new_clip
, clip2
, RGN_OR
);
624 DeleteObject (clip2
);
627 SelectClipRgn (s
->hdc
, new_clip
);
628 DeleteObject (new_clip
);
631 /* Using OPAQUE background mode can clear more background than expected
632 when Cleartype is used. Draw the background manually to avoid this. */
633 SetBkMode (s
->hdc
, TRANSPARENT
);
638 struct font
*font
= s
->font
;
640 brush
= CreateSolidBrush (s
->gc
->background
);
642 rect
.top
= y
- font
->ascent
;
643 rect
.right
= x
+ s
->width
;
644 rect
.bottom
= y
+ font
->descent
;
645 FillRect (s
->hdc
, &rect
, brush
);
646 DeleteObject (brush
);
653 for (i
= 0; i
< len
; i
++)
654 ExtTextOutW (s
->hdc
, x
+ i
, y
, options
, NULL
,
655 s
->char2b
+ from
+ i
, 1, NULL
);
658 ExtTextOutW (s
->hdc
, x
, y
, options
, NULL
, s
->char2b
+ from
, len
, NULL
);
660 /* Restore clip region. */
661 if (s
->num_clips
> 0)
662 SelectClipRgn (s
->hdc
, orig_clip
);
665 DeleteObject (orig_clip
);
670 /* w32 implementation of free_entity for font backend.
671 Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
672 Free FONT_EXTRA_INDEX field of FONT_ENTITY.
674 w32font_free_entity (Lisp_Object entity);
677 /* w32 implementation of prepare_face for font backend.
678 Optional (if FACE->extra is not used).
679 Prepare FACE for displaying characters by FONT on frame F by
680 storing some data in FACE->extra. If successful, return 0.
681 Otherwise, return -1.
683 w32font_prepare_face (struct frame *f, struct face *face);
685 /* w32 implementation of done_face for font backend.
687 Done FACE for displaying characters by FACE->font on frame F.
689 w32font_done_face (struct frame *f, struct face *face); */
691 /* w32 implementation of get_bitmap for font backend.
693 Store bitmap data for glyph-code CODE of FONT in BITMAP. It is
694 intended that this method is called from the other font-driver
697 w32font_get_bitmap (struct font *font, unsigned code,
698 struct font_bitmap *bitmap, int bits_per_pixel);
700 /* w32 implementation of free_bitmap for font backend.
702 Free bitmap data in BITMAP.
704 w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
706 /* w32 implementation of anchor_point for font backend.
708 Get coordinates of the INDEXth anchor point of the glyph whose
709 code is CODE. Store the coordinates in *X and *Y. Return 0 if
710 the operations was successful. Otherwise return -1.
712 w32font_anchor_point (struct font *font, unsigned code,
713 int index, int *x, int *y);
715 /* w32 implementation of otf_capability for font backend.
717 Return a list describing which scripts/languages FONT
718 supports by which GSUB/GPOS features of OpenType tables.
720 w32font_otf_capability (struct font *font);
722 /* w32 implementation of otf_drive for font backend.
724 Apply FONT's OTF-FEATURES to the glyph string.
726 FEATURES specifies which OTF features to apply in this format:
727 (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
728 See the documentation of `font-drive-otf' for the detail.
730 This method applies the specified features to the codes in the
731 elements of GSTRING-IN (between FROMth and TOth). The output
732 codes are stored in GSTRING-OUT at the IDXth element and the
735 Return the number of output codes. If none of the features are
736 applicable to the input data, return 0. If GSTRING-OUT is too
739 w32font_otf_drive (struct font *font, Lisp_Object features,
740 Lisp_Object gstring_in, int from, int to,
741 Lisp_Object gstring_out, int idx,
742 bool alternate_subst);
745 /* Internal implementation of w32font_list.
746 Additional parameter opentype_only restricts the returned fonts to
747 opentype fonts, which can be used with the Uniscribe backend. */
749 w32font_list_internal (struct frame
*f
, Lisp_Object font_spec
,
752 struct font_callback_data match_data
;
755 match_data
.orig_font_spec
= font_spec
;
756 match_data
.list
= Qnil
;
757 XSETFRAME (match_data
.frame
, f
);
759 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
760 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
762 /* If the charset is unrecognized, then we won't find a font, so don't
763 waste time looking for one. */
764 if (match_data
.pattern
.lfCharSet
== DEFAULT_CHARSET
)
766 Lisp_Object spec_charset
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
767 if (!NILP (spec_charset
)
768 && !EQ (spec_charset
, Qiso10646_1
)
769 && !EQ (spec_charset
, Qunicode_bmp
)
770 && !EQ (spec_charset
, Qunicode_sip
)
771 && !EQ (spec_charset
, Qunknown
))
775 match_data
.opentype_only
= opentype_only
;
777 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
779 if (match_data
.pattern
.lfFaceName
[0] == '\0')
781 /* EnumFontFamiliesEx does not take other fields into account if
782 font name is blank, so need to use two passes. */
783 list_all_matching_fonts (&match_data
);
787 dc
= get_frame_dc (f
);
789 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
790 (FONTENUMPROC
) add_font_entity_to_list
,
791 (LPARAM
) &match_data
, 0);
792 release_frame_dc (f
, dc
);
795 return match_data
.list
;
798 /* Internal implementation of w32font_match.
799 Additional parameter opentype_only restricts the returned fonts to
800 opentype fonts, which can be used with the Uniscribe backend. */
802 w32font_match_internal (struct frame
*f
, Lisp_Object font_spec
,
805 struct font_callback_data match_data
;
808 match_data
.orig_font_spec
= font_spec
;
809 XSETFRAME (match_data
.frame
, f
);
810 match_data
.list
= Qnil
;
812 memset (&match_data
.pattern
, 0, sizeof (LOGFONT
));
813 fill_in_logfont (f
, &match_data
.pattern
, font_spec
);
815 match_data
.opentype_only
= opentype_only
;
817 match_data
.pattern
.lfOutPrecision
= OUT_OUTLINE_PRECIS
;
819 dc
= get_frame_dc (f
);
821 EnumFontFamiliesEx (dc
, &match_data
.pattern
,
822 (FONTENUMPROC
) add_one_font_entity_to_list
,
823 (LPARAM
) &match_data
, 0);
824 release_frame_dc (f
, dc
);
826 return NILP (match_data
.list
) ? Qnil
: XCAR (match_data
.list
);
830 w32font_open_internal (struct frame
*f
, Lisp_Object font_entity
,
831 int pixel_size
, Lisp_Object font_object
)
836 HFONT hfont
, old_font
;
838 struct w32font_info
*w32_font
;
840 OUTLINETEXTMETRICW
* metrics
= NULL
;
842 w32_font
= (struct w32font_info
*) XFONT_OBJECT (font_object
);
843 font
= (struct font
*) w32_font
;
848 memset (&logfont
, 0, sizeof (logfont
));
849 fill_in_logfont (f
, &logfont
, font_entity
);
851 /* Prefer truetype fonts, to avoid known problems with type1 fonts, and
852 limitations in bitmap fonts. */
853 val
= AREF (font_entity
, FONT_FOUNDRY_INDEX
);
854 if (!EQ (val
, Qraster
))
855 logfont
.lfOutPrecision
= OUT_TT_PRECIS
;
857 size
= XINT (AREF (font_entity
, FONT_SIZE_INDEX
));
861 logfont
.lfHeight
= -size
;
862 hfont
= CreateFontIndirect (&logfont
);
867 /* Get the metrics for this font. */
868 dc
= get_frame_dc (f
);
869 old_font
= SelectObject (dc
, hfont
);
871 /* Try getting the outline metrics (only works for truetype fonts). */
872 len
= get_outline_metrics_w (dc
, 0, NULL
);
875 metrics
= (OUTLINETEXTMETRICW
*) alloca (len
);
876 if (get_outline_metrics_w (dc
, len
, metrics
))
877 memcpy (&w32_font
->metrics
, &metrics
->otmTextMetrics
,
878 sizeof (TEXTMETRICW
));
884 get_text_metrics_w (dc
, &w32_font
->metrics
);
886 w32_font
->cached_metrics
= NULL
;
887 w32_font
->n_cache_blocks
= 0;
889 SelectObject (dc
, old_font
);
890 release_frame_dc (f
, dc
);
892 w32_font
->hfont
= hfont
;
897 /* We don't know how much space we need for the full name, so start with
898 96 bytes and go up in steps of 32. */
901 while (name
&& w32font_full_name (&logfont
, font_entity
, pixel_size
,
908 font
->props
[FONT_FULLNAME_INDEX
]
909 = DECODE_SYSTEM (build_string (name
));
911 font
->props
[FONT_FULLNAME_INDEX
]
912 = DECODE_SYSTEM (build_string (logfont
.lfFaceName
));
915 font
->max_width
= w32_font
->metrics
.tmMaxCharWidth
;
916 /* Parts of Emacs display assume that height = ascent + descent...
917 so height is defined later, after ascent and descent.
918 font->height = w32_font->metrics.tmHeight
919 + w32_font->metrics.tmExternalLeading;
922 font
->space_width
= font
->average_width
= w32_font
->metrics
.tmAveCharWidth
;
924 font
->vertical_centering
= 0;
925 font
->baseline_offset
= 0;
926 font
->relative_compose
= 0;
927 font
->default_ascent
= w32_font
->metrics
.tmAscent
;
928 font
->pixel_size
= size
;
929 font
->driver
= &w32font_driver
;
930 font
->encoding_charset
= -1;
931 font
->repertory_charset
= -1;
932 /* TODO: do we really want the minimum width here, which could be negative? */
933 font
->min_width
= font
->space_width
;
934 font
->ascent
= w32_font
->metrics
.tmAscent
;
935 font
->descent
= w32_font
->metrics
.tmDescent
;
936 font
->height
= font
->ascent
+ font
->descent
;
940 font
->underline_thickness
= metrics
->otmsUnderscoreSize
;
941 font
->underline_position
= -metrics
->otmsUnderscorePosition
;
945 font
->underline_thickness
= 0;
946 font
->underline_position
= -1;
949 /* For temporary compatibility with legacy code that expects the
950 name to be usable in x-list-fonts. Eventually we expect to change
951 x-list-fonts and other places that use fonts so that this can be
952 an fcname or similar. */
953 font
->props
[FONT_NAME_INDEX
] = Ffont_xlfd_name (font_object
, Qnil
);
958 /* Callback function for EnumFontFamiliesEx.
959 * Adds the name of a font to a Lisp list (passed in as the lParam arg). */
960 static int CALLBACK ALIGN_STACK
961 add_font_name_to_list (ENUMLOGFONTEX
*logical_font
,
962 NEWTEXTMETRICEX
*physical_font
,
963 DWORD font_type
, LPARAM list_object
)
965 Lisp_Object
* list
= (Lisp_Object
*) list_object
;
968 /* Skip vertical fonts (intended only for printing) */
969 if (logical_font
->elfLogFont
.lfFaceName
[0] == '@')
972 family
= intern_font_name (logical_font
->elfLogFont
.lfFaceName
);
973 if (! memq_no_quit (family
, *list
))
974 *list
= Fcons (family
, *list
);
979 static int w32_decode_weight (int);
980 static int w32_encode_weight (int);
982 /* Convert an enumerated Windows font to an Emacs font entity. */
984 w32_enumfont_pattern_entity (Lisp_Object frame
,
985 ENUMLOGFONTEX
*logical_font
,
986 NEWTEXTMETRICEX
*physical_font
,
988 LOGFONT
*requested_font
,
991 Lisp_Object entity
, tem
;
992 LOGFONT
*lf
= (LOGFONT
*) logical_font
;
994 DWORD full_type
= physical_font
->ntmTm
.ntmFlags
;
996 entity
= font_make_entity ();
998 ASET (entity
, FONT_TYPE_INDEX
, backend
);
999 ASET (entity
, FONT_REGISTRY_INDEX
, w32_registry (lf
->lfCharSet
, font_type
));
1000 ASET (entity
, FONT_OBJLIST_INDEX
, Qnil
);
1002 /* Foundry is difficult to get in readable form on Windows.
1003 But Emacs crashes if it is not set, so set it to something more
1004 generic. These values make xlfds compatible with Emacs 22. */
1005 if (lf
->lfOutPrecision
== OUT_STRING_PRECIS
)
1007 else if (lf
->lfOutPrecision
== OUT_STROKE_PRECIS
)
1012 ASET (entity
, FONT_FOUNDRY_INDEX
, tem
);
1014 /* Save the generic family in the extra info, as it is likely to be
1015 useful to users looking for a close match. */
1016 generic_type
= physical_font
->ntmTm
.tmPitchAndFamily
& 0xF0;
1017 if (generic_type
== FF_DECORATIVE
)
1019 else if (generic_type
== FF_MODERN
)
1021 else if (generic_type
== FF_ROMAN
)
1023 else if (generic_type
== FF_SCRIPT
)
1025 else if (generic_type
== FF_SWISS
)
1030 ASET (entity
, FONT_ADSTYLE_INDEX
, tem
);
1032 if (physical_font
->ntmTm
.tmPitchAndFamily
& 0x01)
1033 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_PROPORTIONAL
));
1035 ASET (entity
, FONT_SPACING_INDEX
, make_number (FONT_SPACING_CHARCELL
));
1037 if (requested_font
->lfQuality
!= DEFAULT_QUALITY
)
1039 font_put_extra (entity
, QCantialias
,
1040 lispy_antialias_type (requested_font
->lfQuality
));
1042 ASET (entity
, FONT_FAMILY_INDEX
,
1043 intern_font_name (lf
->lfFaceName
));
1045 FONT_SET_STYLE (entity
, FONT_WEIGHT_INDEX
,
1046 make_number (w32_decode_weight (lf
->lfWeight
)));
1047 FONT_SET_STYLE (entity
, FONT_SLANT_INDEX
,
1048 make_number (lf
->lfItalic
? 200 : 100));
1049 /* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
1051 FONT_SET_STYLE (entity
, FONT_WIDTH_INDEX
, make_number (100));
1053 if (font_type
& RASTER_FONTTYPE
)
1054 ASET (entity
, FONT_SIZE_INDEX
,
1055 make_number (physical_font
->ntmTm
.tmHeight
1056 + physical_font
->ntmTm
.tmExternalLeading
));
1058 ASET (entity
, FONT_SIZE_INDEX
, make_number (0));
1060 /* Cache Unicode codepoints covered by this font, as there is no other way
1061 of getting this information easily. */
1062 if (font_type
& TRUETYPE_FONTTYPE
)
1064 tem
= font_supported_scripts (&physical_font
->ntmFontSig
);
1066 font_put_extra (entity
, QCscript
, tem
);
1069 /* This information is not fully available when opening fonts, so
1070 save it here. Only Windows 2000 and later return information
1071 about opentype and type1 fonts, so need a fallback for detecting
1072 truetype so that this information is not any worse than we could
1073 have obtained later. */
1074 if (EQ (backend
, Quniscribe
) && (full_type
& NTMFLAGS_OPENTYPE
))
1076 else if (font_type
& TRUETYPE_FONTTYPE
)
1077 tem
= intern ("truetype");
1078 else if (full_type
& NTM_PS_OPENTYPE
)
1080 else if (full_type
& NTM_TYPE1
)
1081 tem
= intern ("type1");
1082 else if (font_type
& RASTER_FONTTYPE
)
1083 tem
= intern ("w32bitmap");
1085 tem
= intern ("w32vector");
1087 font_put_extra (entity
, QCformat
, tem
);
1093 /* Convert generic families to the family portion of lfPitchAndFamily. */
1095 w32_generic_family (Lisp_Object name
)
1097 /* Generic families. */
1098 if (EQ (name
, Qmonospace
) || EQ (name
, Qmono
))
1100 else if (EQ (name
, Qsans
) || EQ (name
, Qsans_serif
) || EQ (name
, Qsansserif
))
1102 else if (EQ (name
, Qserif
))
1104 else if (EQ (name
, Qdecorative
))
1105 return FF_DECORATIVE
;
1106 else if (EQ (name
, Qscript
))
1113 logfonts_match (LOGFONT
*font
, LOGFONT
*pattern
)
1115 /* Only check height for raster fonts. */
1116 if (pattern
->lfHeight
&& font
->lfOutPrecision
== OUT_STRING_PRECIS
1117 && font
->lfHeight
!= pattern
->lfHeight
)
1120 /* Have some flexibility with weights. */
1121 if (pattern
->lfWeight
1122 && ((font
->lfWeight
< (pattern
->lfWeight
- 150))
1123 || font
->lfWeight
> (pattern
->lfWeight
+ 150)))
1126 /* Charset and face should be OK. Italic has to be checked
1127 against the original spec, in case we don't have any preference. */
1131 /* Codepage Bitfields in FONTSIGNATURE struct. */
1132 #define CSB_JAPANESE (1 << 17)
1133 #define CSB_KOREAN ((1 << 19) | (1 << 21))
1134 #define CSB_CHINESE ((1 << 18) | (1 << 20))
1137 font_matches_spec (DWORD type
, NEWTEXTMETRICEX
*font
,
1138 Lisp_Object spec
, Lisp_Object backend
,
1141 Lisp_Object extra
, val
;
1143 /* Check italic. Can't check logfonts, since it is a boolean field,
1144 so there is no difference between "non-italic" and "don't care". */
1146 int slant
= FONT_SLANT_NUMERIC (spec
);
1149 && ((slant
> 150 && !font
->ntmTm
.tmItalic
)
1150 || (slant
<= 150 && font
->ntmTm
.tmItalic
)))
1154 /* Check adstyle against generic family. */
1155 val
= AREF (spec
, FONT_ADSTYLE_INDEX
);
1158 BYTE family
= w32_generic_family (val
);
1159 if (family
!= FF_DONTCARE
1160 && family
!= (font
->ntmTm
.tmPitchAndFamily
& 0xF0))
1165 val
= AREF (spec
, FONT_SPACING_INDEX
);
1168 int spacing
= XINT (val
);
1169 int proportional
= (spacing
< FONT_SPACING_MONO
);
1171 if ((proportional
&& !(font
->ntmTm
.tmPitchAndFamily
& 0x01))
1172 || (!proportional
&& (font
->ntmTm
.tmPitchAndFamily
& 0x01)))
1176 /* Check extra parameters. */
1177 for (extra
= AREF (spec
, FONT_EXTRA_INDEX
);
1178 CONSP (extra
); extra
= XCDR (extra
))
1180 Lisp_Object extra_entry
;
1181 extra_entry
= XCAR (extra
);
1182 if (CONSP (extra_entry
))
1184 Lisp_Object key
= XCAR (extra_entry
);
1186 val
= XCDR (extra_entry
);
1187 if (EQ (key
, QCscript
) && SYMBOLP (val
))
1189 /* Only truetype fonts will have information about what
1190 scripts they support. This probably means the user
1191 will have to force Emacs to use raster, PostScript
1192 or ATM fonts for non-ASCII text. */
1193 if (type
& TRUETYPE_FONTTYPE
)
1196 = font_supported_scripts (&font
->ntmFontSig
);
1197 if (! memq_no_quit (val
, support
))
1200 /* Avoid using non-Japanese fonts for Japanese, even
1201 if they claim they are capable, due to known
1202 breakage in Vista and Windows 7 fonts
1205 && (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
1206 || !(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
)))
1211 /* Return specific matches, but play it safe. Fonts
1212 that cover more than their charset would suggest
1213 are likely to be truetype or opentype fonts,
1215 if (EQ (val
, Qlatin
))
1217 /* Although every charset but symbol, thai and
1218 arabic contains the basic ASCII set of latin
1219 characters, Emacs expects much more. */
1220 if (font
->ntmTm
.tmCharSet
!= ANSI_CHARSET
)
1223 else if (EQ (val
, Qsymbol
))
1225 if (font
->ntmTm
.tmCharSet
!= SYMBOL_CHARSET
)
1228 else if (EQ (val
, Qcyrillic
))
1230 if (font
->ntmTm
.tmCharSet
!= RUSSIAN_CHARSET
)
1233 else if (EQ (val
, Qgreek
))
1235 if (font
->ntmTm
.tmCharSet
!= GREEK_CHARSET
)
1238 else if (EQ (val
, Qarabic
))
1240 if (font
->ntmTm
.tmCharSet
!= ARABIC_CHARSET
)
1243 else if (EQ (val
, Qhebrew
))
1245 if (font
->ntmTm
.tmCharSet
!= HEBREW_CHARSET
)
1248 else if (EQ (val
, Qthai
))
1250 if (font
->ntmTm
.tmCharSet
!= THAI_CHARSET
)
1253 else if (EQ (val
, Qkana
))
1255 if (font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1258 else if (EQ (val
, Qbopomofo
))
1260 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
)
1263 else if (EQ (val
, Qhangul
))
1265 if (font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1266 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
)
1269 else if (EQ (val
, Qhan
))
1271 if (font
->ntmTm
.tmCharSet
!= CHINESEBIG5_CHARSET
1272 && font
->ntmTm
.tmCharSet
!= GB2312_CHARSET
1273 && font
->ntmTm
.tmCharSet
!= HANGUL_CHARSET
1274 && font
->ntmTm
.tmCharSet
!= JOHAB_CHARSET
1275 && font
->ntmTm
.tmCharSet
!= SHIFTJIS_CHARSET
)
1279 /* Other scripts unlikely to be handled by non-truetype
1284 else if (EQ (key
, QClang
) && SYMBOLP (val
))
1286 /* Just handle the CJK languages here, as the lang
1287 parameter is used to select a font with appropriate
1288 glyphs in the cjk unified ideographs block. Other fonts
1289 support for a language can be solely determined by
1290 its character coverage. */
1293 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1296 else if (EQ (val
, Qko
))
1298 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_KOREAN
))
1301 else if (EQ (val
, Qzh
))
1303 if (!(font
->ntmFontSig
.fsCsb
[0] & CSB_CHINESE
))
1307 /* Any other language, we don't recognize it. Only the above
1308 currently appear in fontset.el, so it isn't worth
1309 creating a mapping table of codepages/scripts to languages
1310 or opening the font to see if there are any language tags
1311 in it that the Windows API does not expose. Fontset
1312 spec should have a fallback, as some backends do
1313 not recognize language at all. */
1316 else if (EQ (key
, QCotf
) && CONSP (val
))
1318 /* OTF features only supported by the uniscribe backend. */
1319 if (EQ (backend
, Quniscribe
))
1321 if (!uniscribe_check_otf (logfont
, val
))
1333 w32font_coverage_ok (FONTSIGNATURE
* coverage
, BYTE charset
)
1335 DWORD subrange1
= coverage
->fsUsb
[1];
1337 #define SUBRANGE1_HAN_MASK 0x08000000
1338 #define SUBRANGE1_HANGEUL_MASK 0x01000000
1339 #define SUBRANGE1_JAPANESE_MASK (0x00060000 | SUBRANGE1_HAN_MASK)
1341 if (charset
== GB2312_CHARSET
|| charset
== CHINESEBIG5_CHARSET
)
1343 return (subrange1
& SUBRANGE1_HAN_MASK
) == SUBRANGE1_HAN_MASK
;
1345 else if (charset
== SHIFTJIS_CHARSET
)
1347 return (subrange1
& SUBRANGE1_JAPANESE_MASK
) == SUBRANGE1_JAPANESE_MASK
;
1349 else if (charset
== HANGEUL_CHARSET
)
1351 return (subrange1
& SUBRANGE1_HANGEUL_MASK
) == SUBRANGE1_HANGEUL_MASK
;
1358 #define _strlwr strlwr
1359 #endif /* !WINDOWSNT */
1362 check_face_name (LOGFONT
*font
, char *full_name
)
1364 char full_iname
[LF_FULLFACESIZE
+1];
1366 /* Just check for names known to cause problems, since the full name
1367 can contain expanded abbreviations, prefixed foundry, postfixed
1368 style, the latter of which sometimes differs from the style indicated
1369 in the shorter name (eg Lt becomes Light or even Extra Light) */
1371 /* Helvetica is mapped to Arial in Windows, but if a Type-1 Helvetica is
1372 installed, we run into problems with the Uniscribe backend which tries
1373 to avoid non-truetype fonts, and ends up mixing the Type-1 Helvetica
1374 with Arial's characteristics, since that attempt to use TrueType works
1375 some places, but not others. */
1376 if (!xstrcasecmp (font
->lfFaceName
, "helvetica"))
1378 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1379 full_iname
[LF_FULLFACESIZE
] = 0;
1380 _strlwr (full_iname
);
1381 return strstr ("helvetica", full_iname
) != NULL
;
1383 /* Same for Helv. */
1384 if (!xstrcasecmp (font
->lfFaceName
, "helv"))
1386 strncpy (full_iname
, full_name
, LF_FULLFACESIZE
);
1387 full_iname
[LF_FULLFACESIZE
] = 0;
1388 _strlwr (full_iname
);
1389 return strstr ("helv", full_iname
) != NULL
;
1392 /* Since Times is mapped to Times New Roman, a substring
1393 match is not sufficient to filter out the bogus match. */
1394 else if (!xstrcasecmp (font
->lfFaceName
, "times"))
1395 return xstrcasecmp (full_name
, "times") == 0;
1401 /* Callback function for EnumFontFamiliesEx.
1402 * Checks if a font matches everything we are trying to check against,
1403 * and if so, adds it to a list. Both the data we are checking against
1404 * and the list to which the fonts are added are passed in via the
1405 * lparam argument, in the form of a font_callback_data struct. */
1406 static int CALLBACK ALIGN_STACK
1407 add_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1408 NEWTEXTMETRICEX
*physical_font
,
1409 DWORD font_type
, LPARAM lParam
)
1411 struct font_callback_data
*match_data
1412 = (struct font_callback_data
*) lParam
;
1413 Lisp_Object backend
= match_data
->opentype_only
? Quniscribe
: Qgdi
;
1416 int is_unicode
= physical_font
->ntmFontSig
.fsUsb
[3]
1417 || physical_font
->ntmFontSig
.fsUsb
[2]
1418 || physical_font
->ntmFontSig
.fsUsb
[1]
1419 || physical_font
->ntmFontSig
.fsUsb
[0] & 0x3fffffff;
1421 /* Skip non matching fonts. */
1423 /* For uniscribe backend, consider only truetype or opentype fonts
1424 that have some Unicode coverage. */
1425 if (match_data
->opentype_only
1426 && ((!(physical_font
->ntmTm
.ntmFlags
& NTMFLAGS_OPENTYPE
)
1427 && !(font_type
& TRUETYPE_FONTTYPE
))
1431 /* Ensure a match. */
1432 if (!logfonts_match (&logical_font
->elfLogFont
, &match_data
->pattern
)
1433 || !font_matches_spec (font_type
, physical_font
,
1434 match_data
->orig_font_spec
, backend
,
1435 &logical_font
->elfLogFont
)
1436 || !w32font_coverage_ok (&physical_font
->ntmFontSig
,
1437 match_data
->pattern
.lfCharSet
))
1440 /* Avoid substitutions involving raster fonts (eg Helv -> MS Sans Serif)
1441 We limit this to raster fonts, because the test can catch some
1442 genuine fonts (eg the full name of DejaVu Sans Mono Light is actually
1443 DejaVu Sans Mono ExtraLight). Helvetica -> Arial substitution will
1444 therefore get through this test. Since full names can be prefixed
1445 by a foundry, we accept raster fonts if the font name is found
1446 anywhere within the full name. */
1447 if ((logical_font
->elfLogFont
.lfOutPrecision
== OUT_STRING_PRECIS
1448 && !strstr (logical_font
->elfFullName
,
1449 logical_font
->elfLogFont
.lfFaceName
))
1450 /* Check for well known substitutions that mess things up in the
1451 presence of Type-1 fonts of the same name. */
1452 || (!check_face_name (&logical_font
->elfLogFont
,
1453 logical_font
->elfFullName
)))
1456 /* Make a font entity for the font. */
1457 entity
= w32_enumfont_pattern_entity (match_data
->frame
, logical_font
,
1458 physical_font
, font_type
,
1459 &match_data
->pattern
,
1464 Lisp_Object spec_charset
= AREF (match_data
->orig_font_spec
,
1465 FONT_REGISTRY_INDEX
);
1467 /* iso10646-1 fonts must contain Unicode mapping tables. */
1468 if (EQ (spec_charset
, Qiso10646_1
))
1473 /* unicode-bmp fonts must contain characters from the BMP. */
1474 else if (EQ (spec_charset
, Qunicode_bmp
))
1476 if (!physical_font
->ntmFontSig
.fsUsb
[3]
1477 && !(physical_font
->ntmFontSig
.fsUsb
[2] & 0xFFFFFF9E)
1478 && !(physical_font
->ntmFontSig
.fsUsb
[1] & 0xE81FFFFF)
1479 && !(physical_font
->ntmFontSig
.fsUsb
[0] & 0x007F001F))
1482 /* unicode-sip fonts must contain characters in Unicode plane 2.
1483 so look for bit 57 (surrogates) in the Unicode subranges, plus
1484 the bits for CJK ranges that include those characters. */
1485 else if (EQ (spec_charset
, Qunicode_sip
))
1487 if (!(physical_font
->ntmFontSig
.fsUsb
[1] & 0x02000000)
1488 || !(physical_font
->ntmFontSig
.fsUsb
[1] & 0x28000000))
1492 /* This font matches. */
1494 /* If registry was specified, ensure it is reported as the same. */
1495 if (!NILP (spec_charset
))
1497 /* Avoid using non-Japanese fonts for Japanese, even if they
1498 claim they are capable, due to known breakage in Vista
1499 and Windows 7 fonts (bug#6029). */
1500 if (logical_font
->elfLogFont
.lfCharSet
== SHIFTJIS_CHARSET
1501 && !(physical_font
->ntmFontSig
.fsCsb
[0] & CSB_JAPANESE
))
1504 ASET (entity
, FONT_REGISTRY_INDEX
, spec_charset
);
1506 /* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
1507 fonts as Unicode and skip other charsets. */
1508 else if (match_data
->opentype_only
)
1510 if (logical_font
->elfLogFont
.lfCharSet
== ANSI_CHARSET
1511 || logical_font
->elfLogFont
.lfCharSet
== DEFAULT_CHARSET
)
1512 ASET (entity
, FONT_REGISTRY_INDEX
, Qiso10646_1
);
1517 /* Add this font to the list. */
1518 match_data
->list
= Fcons (entity
, match_data
->list
);
1523 /* Callback function for EnumFontFamiliesEx.
1524 * Terminates the search once we have a match. */
1525 static int CALLBACK ALIGN_STACK
1526 add_one_font_entity_to_list (ENUMLOGFONTEX
*logical_font
,
1527 NEWTEXTMETRICEX
*physical_font
,
1528 DWORD font_type
, LPARAM lParam
)
1530 struct font_callback_data
*match_data
1531 = (struct font_callback_data
*) lParam
;
1532 add_font_entity_to_list (logical_font
, physical_font
, font_type
, lParam
);
1534 /* If we have a font in the list, terminate the search. */
1535 return NILP (match_data
->list
);
1538 /* Old function to convert from x to w32 charset, from w32fns.c. */
1540 x_to_w32_charset (char * lpcs
)
1542 Lisp_Object this_entry
, w32_charset
;
1544 int len
= strlen (lpcs
);
1546 /* Support "*-#nnn" format for unknown charsets. */
1547 if (strncmp (lpcs
, "*-#", 3) == 0)
1548 return atoi (lpcs
+ 3);
1550 /* All Windows fonts qualify as Unicode. */
1551 if (!strncmp (lpcs
, "iso10646", 8))
1552 return DEFAULT_CHARSET
;
1554 /* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */
1555 charset
= alloca (len
+ 1);
1556 strcpy (charset
, lpcs
);
1557 lpcs
= strchr (charset
, '*');
1561 /* Look through w32-charset-info-alist for the character set.
1562 Format of each entry is
1563 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1565 this_entry
= Fassoc (build_string (charset
), Vw32_charset_info_alist
);
1567 if (NILP (this_entry
))
1569 /* At startup, we want iso8859-1 fonts to come up properly. */
1570 if (xstrcasecmp (charset
, "iso8859-1") == 0)
1571 return ANSI_CHARSET
;
1573 return DEFAULT_CHARSET
;
1576 w32_charset
= Fcar (Fcdr (this_entry
));
1578 /* Translate Lisp symbol to number. */
1579 if (EQ (w32_charset
, Qw32_charset_ansi
))
1580 return ANSI_CHARSET
;
1581 if (EQ (w32_charset
, Qw32_charset_symbol
))
1582 return SYMBOL_CHARSET
;
1583 if (EQ (w32_charset
, Qw32_charset_shiftjis
))
1584 return SHIFTJIS_CHARSET
;
1585 if (EQ (w32_charset
, Qw32_charset_hangeul
))
1586 return HANGEUL_CHARSET
;
1587 if (EQ (w32_charset
, Qw32_charset_chinesebig5
))
1588 return CHINESEBIG5_CHARSET
;
1589 if (EQ (w32_charset
, Qw32_charset_gb2312
))
1590 return GB2312_CHARSET
;
1591 if (EQ (w32_charset
, Qw32_charset_oem
))
1593 if (EQ (w32_charset
, Qw32_charset_johab
))
1594 return JOHAB_CHARSET
;
1595 if (EQ (w32_charset
, Qw32_charset_easteurope
))
1596 return EASTEUROPE_CHARSET
;
1597 if (EQ (w32_charset
, Qw32_charset_turkish
))
1598 return TURKISH_CHARSET
;
1599 if (EQ (w32_charset
, Qw32_charset_baltic
))
1600 return BALTIC_CHARSET
;
1601 if (EQ (w32_charset
, Qw32_charset_russian
))
1602 return RUSSIAN_CHARSET
;
1603 if (EQ (w32_charset
, Qw32_charset_arabic
))
1604 return ARABIC_CHARSET
;
1605 if (EQ (w32_charset
, Qw32_charset_greek
))
1606 return GREEK_CHARSET
;
1607 if (EQ (w32_charset
, Qw32_charset_hebrew
))
1608 return HEBREW_CHARSET
;
1609 if (EQ (w32_charset
, Qw32_charset_vietnamese
))
1610 return VIETNAMESE_CHARSET
;
1611 if (EQ (w32_charset
, Qw32_charset_thai
))
1612 return THAI_CHARSET
;
1613 if (EQ (w32_charset
, Qw32_charset_mac
))
1616 return DEFAULT_CHARSET
;
1620 /* Convert a Lisp font registry (symbol) to a windows charset. */
1622 registry_to_w32_charset (Lisp_Object charset
)
1624 if (EQ (charset
, Qiso10646_1
) || EQ (charset
, Qunicode_bmp
)
1625 || EQ (charset
, Qunicode_sip
))
1626 return DEFAULT_CHARSET
; /* UNICODE_CHARSET not defined in MingW32 */
1627 else if (EQ (charset
, Qiso8859_1
))
1628 return ANSI_CHARSET
;
1629 else if (SYMBOLP (charset
))
1630 return x_to_w32_charset (SDATA (SYMBOL_NAME (charset
)));
1632 return DEFAULT_CHARSET
;
1635 /* Old function to convert from w32 to x charset, from w32fns.c. */
1637 w32_to_x_charset (int fncharset
, char *matching
)
1639 static char buf
[32];
1640 Lisp_Object charset_type
;
1645 /* If fully specified, accept it as it is. Otherwise use a
1647 char *wildcard
= strchr (matching
, '*');
1650 else if (strchr (matching
, '-'))
1653 match_len
= strlen (matching
);
1659 /* Handle startup case of w32-charset-info-alist not
1660 being set up yet. */
1661 if (NILP (Vw32_charset_info_alist
))
1663 charset_type
= Qw32_charset_ansi
;
1665 case DEFAULT_CHARSET
:
1666 charset_type
= Qw32_charset_default
;
1668 case SYMBOL_CHARSET
:
1669 charset_type
= Qw32_charset_symbol
;
1671 case SHIFTJIS_CHARSET
:
1672 charset_type
= Qw32_charset_shiftjis
;
1674 case HANGEUL_CHARSET
:
1675 charset_type
= Qw32_charset_hangeul
;
1677 case GB2312_CHARSET
:
1678 charset_type
= Qw32_charset_gb2312
;
1680 case CHINESEBIG5_CHARSET
:
1681 charset_type
= Qw32_charset_chinesebig5
;
1684 charset_type
= Qw32_charset_oem
;
1686 case EASTEUROPE_CHARSET
:
1687 charset_type
= Qw32_charset_easteurope
;
1689 case TURKISH_CHARSET
:
1690 charset_type
= Qw32_charset_turkish
;
1692 case BALTIC_CHARSET
:
1693 charset_type
= Qw32_charset_baltic
;
1695 case RUSSIAN_CHARSET
:
1696 charset_type
= Qw32_charset_russian
;
1698 case ARABIC_CHARSET
:
1699 charset_type
= Qw32_charset_arabic
;
1702 charset_type
= Qw32_charset_greek
;
1704 case HEBREW_CHARSET
:
1705 charset_type
= Qw32_charset_hebrew
;
1707 case VIETNAMESE_CHARSET
:
1708 charset_type
= Qw32_charset_vietnamese
;
1711 charset_type
= Qw32_charset_thai
;
1714 charset_type
= Qw32_charset_mac
;
1717 charset_type
= Qw32_charset_johab
;
1721 /* Encode numerical value of unknown charset. */
1722 sprintf (buf
, "*-#%u", fncharset
);
1728 char * best_match
= NULL
;
1729 int matching_found
= 0;
1731 /* Look through w32-charset-info-alist for the character set.
1732 Prefer ISO codepages, and prefer lower numbers in the ISO
1733 range. Only return charsets for codepages which are installed.
1735 Format of each entry is
1736 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1738 for (rest
= Vw32_charset_info_alist
; CONSP (rest
); rest
= XCDR (rest
))
1741 Lisp_Object w32_charset
;
1742 Lisp_Object codepage
;
1744 Lisp_Object this_entry
= XCAR (rest
);
1746 /* Skip invalid entries in alist. */
1747 if (!CONSP (this_entry
) || !STRINGP (XCAR (this_entry
))
1748 || !CONSP (XCDR (this_entry
))
1749 || !SYMBOLP (XCAR (XCDR (this_entry
))))
1752 x_charset
= SDATA (XCAR (this_entry
));
1753 w32_charset
= XCAR (XCDR (this_entry
));
1754 codepage
= XCDR (XCDR (this_entry
));
1756 /* Look for Same charset and a valid codepage (or non-int
1757 which means ignore). */
1758 if (EQ (w32_charset
, charset_type
)
1759 && (!INTEGERP (codepage
) || XINT (codepage
) == CP_DEFAULT
1760 || IsValidCodePage (XINT (codepage
))))
1762 /* If we don't have a match already, then this is the
1766 best_match
= x_charset
;
1767 if (matching
&& !strnicmp (x_charset
, matching
, match_len
))
1770 /* If we already found a match for MATCHING, then
1771 only consider other matches. */
1772 else if (matching_found
1773 && strnicmp (x_charset
, matching
, match_len
))
1775 /* If this matches what we want, and the best so far doesn't,
1776 then this is better. */
1777 else if (!matching_found
&& matching
1778 && !strnicmp (x_charset
, matching
, match_len
))
1780 best_match
= x_charset
;
1783 /* If this is fully specified, and the best so far isn't,
1784 then this is better. */
1785 else if ((!strchr (best_match
, '-') && strchr (x_charset
, '-'))
1786 /* If this is an ISO codepage, and the best so far isn't,
1787 then this is better, but only if it fully specifies the
1789 || (strnicmp (best_match
, "iso", 3) != 0
1790 && strnicmp (x_charset
, "iso", 3) == 0
1791 && strchr (x_charset
, '-')))
1792 best_match
= x_charset
;
1793 /* If both are ISO8859 codepages, choose the one with the
1794 lowest number in the encoding field. */
1795 else if (strnicmp (best_match
, "iso8859-", 8) == 0
1796 && strnicmp (x_charset
, "iso8859-", 8) == 0)
1798 int best_enc
= atoi (best_match
+ 8);
1799 int this_enc
= atoi (x_charset
+ 8);
1800 if (this_enc
> 0 && this_enc
< best_enc
)
1801 best_match
= x_charset
;
1806 /* If no match, encode the numeric value. */
1809 sprintf (buf
, "*-#%u", fncharset
);
1813 strncpy (buf
, best_match
, 31);
1814 /* If the charset is not fully specified, put -0 on the end. */
1815 if (!strchr (best_match
, '-'))
1817 int pos
= strlen (best_match
);
1818 /* Charset specifiers shouldn't be very long. If it is a made
1819 up one, truncating it should not do any harm since it isn't
1820 recognized anyway. */
1823 strcpy (buf
+ pos
, "-0");
1831 w32_registry (LONG w32_charset
, DWORD font_type
)
1835 /* If charset is defaulted, charset is Unicode or unknown, depending on
1837 if (w32_charset
== DEFAULT_CHARSET
)
1838 return font_type
== TRUETYPE_FONTTYPE
? Qiso10646_1
: Qunknown
;
1840 charset
= w32_to_x_charset (w32_charset
, NULL
);
1841 return font_intern_prop (charset
, strlen (charset
), 1);
1845 w32_decode_weight (int fnweight
)
1847 if (fnweight
>= FW_HEAVY
) return 210;
1848 if (fnweight
>= FW_EXTRABOLD
) return 205;
1849 if (fnweight
>= FW_BOLD
) return 200;
1850 if (fnweight
>= FW_SEMIBOLD
) return 180;
1851 if (fnweight
>= FW_NORMAL
) return 100;
1852 if (fnweight
>= FW_LIGHT
) return 50;
1853 if (fnweight
>= FW_EXTRALIGHT
) return 40;
1854 if (fnweight
> FW_THIN
) return 20;
1859 w32_encode_weight (int n
)
1861 if (n
>= 210) return FW_HEAVY
;
1862 if (n
>= 205) return FW_EXTRABOLD
;
1863 if (n
>= 200) return FW_BOLD
;
1864 if (n
>= 180) return FW_SEMIBOLD
;
1865 if (n
>= 100) return FW_NORMAL
;
1866 if (n
>= 50) return FW_LIGHT
;
1867 if (n
>= 40) return FW_EXTRALIGHT
;
1868 if (n
>= 20) return FW_THIN
;
1872 /* Convert a Windows font weight into one of the weights supported
1873 by fontconfig (see font.c:font_parse_fcname). */
1875 w32_to_fc_weight (int n
)
1877 if (n
>= FW_EXTRABOLD
) return intern ("black");
1878 if (n
>= FW_BOLD
) return Qbold
;
1879 if (n
>= FW_SEMIBOLD
) return intern ("demibold");
1880 if (n
>= FW_NORMAL
) return intern ("medium");
1884 /* Fill in all the available details of LOGFONT from FONT_SPEC. */
1886 fill_in_logfont (struct frame
*f
, LOGFONT
*logfont
, Lisp_Object font_spec
)
1888 Lisp_Object tmp
, extra
;
1889 int dpi
= FRAME_RES_Y (f
);
1891 tmp
= AREF (font_spec
, FONT_DPI_INDEX
);
1896 else if (FLOATP (tmp
))
1898 dpi
= (int) (XFLOAT_DATA (tmp
) + 0.5);
1902 tmp
= AREF (font_spec
, FONT_SIZE_INDEX
);
1904 logfont
->lfHeight
= -1 * XINT (tmp
);
1905 else if (FLOATP (tmp
))
1906 logfont
->lfHeight
= (int) (-1.0 * dpi
* XFLOAT_DATA (tmp
) / 72.27 + 0.5);
1913 tmp
= AREF (font_spec
, FONT_WEIGHT_INDEX
);
1915 logfont
->lfWeight
= w32_encode_weight (FONT_WEIGHT_NUMERIC (font_spec
));
1918 tmp
= AREF (font_spec
, FONT_SLANT_INDEX
);
1921 int slant
= FONT_SLANT_NUMERIC (font_spec
);
1922 logfont
->lfItalic
= slant
> 150 ? 1 : 0;
1930 tmp
= AREF (font_spec
, FONT_REGISTRY_INDEX
);
1932 logfont
->lfCharSet
= registry_to_w32_charset (tmp
);
1934 logfont
->lfCharSet
= DEFAULT_CHARSET
;
1938 /* Clip Precision */
1941 logfont
->lfQuality
= DEFAULT_QUALITY
;
1943 /* Generic Family and Face Name */
1944 logfont
->lfPitchAndFamily
= FF_DONTCARE
| DEFAULT_PITCH
;
1946 tmp
= AREF (font_spec
, FONT_FAMILY_INDEX
);
1949 logfont
->lfPitchAndFamily
= w32_generic_family (tmp
) | DEFAULT_PITCH
;
1950 if ((logfont
->lfPitchAndFamily
& 0xF0) != FF_DONTCARE
)
1951 ; /* Font name was generic, don't fill in font name. */
1952 /* Font families are interned, but allow for strings also in case of
1954 else if (SYMBOLP (tmp
))
1956 strncpy (logfont
->lfFaceName
,
1957 SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp
))), LF_FACESIZE
);
1958 logfont
->lfFaceName
[LF_FACESIZE
-1] = '\0';
1962 tmp
= AREF (font_spec
, FONT_ADSTYLE_INDEX
);
1965 /* Override generic family. */
1966 BYTE family
= w32_generic_family (tmp
);
1967 if (family
!= FF_DONTCARE
)
1968 logfont
->lfPitchAndFamily
= family
| DEFAULT_PITCH
;
1971 /* Set pitch based on the spacing property. */
1972 tmp
= AREF (font_spec
, FONT_SPACING_INDEX
);
1975 int spacing
= XINT (tmp
);
1976 if (spacing
< FONT_SPACING_MONO
)
1977 logfont
->lfPitchAndFamily
1978 = (logfont
->lfPitchAndFamily
& 0xF0) | VARIABLE_PITCH
;
1980 logfont
->lfPitchAndFamily
1981 = (logfont
->lfPitchAndFamily
& 0xF0) | FIXED_PITCH
;
1984 /* Process EXTRA info. */
1985 for (extra
= AREF (font_spec
, FONT_EXTRA_INDEX
);
1986 CONSP (extra
); extra
= XCDR (extra
))
1991 Lisp_Object key
, val
;
1992 key
= XCAR (tmp
), val
= XCDR (tmp
);
1993 /* Only use QCscript if charset is not provided, or is Unicode
1994 and a single script is specified. This is rather crude,
1995 and is only used to narrow down the fonts returned where
1996 there is a definite match. Some scripts, such as latin, han,
1997 cjk-misc match multiple lfCharSet values, so we can't pre-filter
1999 if (EQ (key
, QCscript
)
2000 && logfont
->lfCharSet
== DEFAULT_CHARSET
2003 if (EQ (val
, Qgreek
))
2004 logfont
->lfCharSet
= GREEK_CHARSET
;
2005 else if (EQ (val
, Qhangul
))
2006 logfont
->lfCharSet
= HANGUL_CHARSET
;
2007 else if (EQ (val
, Qkana
) || EQ (val
, Qkanbun
))
2008 logfont
->lfCharSet
= SHIFTJIS_CHARSET
;
2009 else if (EQ (val
, Qbopomofo
))
2010 logfont
->lfCharSet
= CHINESEBIG5_CHARSET
;
2011 /* GB 18030 supports tibetan, yi, mongolian,
2012 fonts that support it should show up if we ask for
2014 else if (EQ (val
, Qtibetan
) || EQ (val
, Qyi
)
2015 || EQ (val
, Qmongolian
))
2016 logfont
->lfCharSet
= GB2312_CHARSET
;
2017 else if (EQ (val
, Qhebrew
))
2018 logfont
->lfCharSet
= HEBREW_CHARSET
;
2019 else if (EQ (val
, Qarabic
))
2020 logfont
->lfCharSet
= ARABIC_CHARSET
;
2021 else if (EQ (val
, Qthai
))
2022 logfont
->lfCharSet
= THAI_CHARSET
;
2024 else if (EQ (key
, QCantialias
) && SYMBOLP (val
))
2026 logfont
->lfQuality
= w32_antialias_type (val
);
2033 list_all_matching_fonts (struct font_callback_data
*match_data
)
2036 Lisp_Object families
= w32font_list_family (XFRAME (match_data
->frame
));
2037 struct frame
*f
= XFRAME (match_data
->frame
);
2039 dc
= get_frame_dc (f
);
2041 while (!NILP (families
))
2043 /* Only fonts from the current locale are given localized names
2044 on Windows, so we can keep backwards compatibility with
2045 Windows 9x/ME by using non-Unicode font enumeration without
2046 sacrificing internationalization here. */
2048 Lisp_Object family
= CAR (families
);
2049 families
= CDR (families
);
2052 else if (SYMBOLP (family
))
2053 name
= SDATA (ENCODE_SYSTEM (SYMBOL_NAME (family
)));
2057 strncpy (match_data
->pattern
.lfFaceName
, name
, LF_FACESIZE
);
2058 match_data
->pattern
.lfFaceName
[LF_FACESIZE
- 1] = '\0';
2060 EnumFontFamiliesEx (dc
, &match_data
->pattern
,
2061 (FONTENUMPROC
) add_font_entity_to_list
,
2062 (LPARAM
) match_data
, 0);
2065 release_frame_dc (f
, dc
);
2069 lispy_antialias_type (BYTE type
)
2075 case NONANTIALIASED_QUALITY
:
2078 case ANTIALIASED_QUALITY
:
2081 case CLEARTYPE_QUALITY
:
2084 case CLEARTYPE_NATURAL_QUALITY
:
2094 /* Convert antialiasing symbols to lfQuality */
2096 w32_antialias_type (Lisp_Object type
)
2098 if (EQ (type
, Qnone
))
2099 return NONANTIALIASED_QUALITY
;
2100 else if (EQ (type
, Qstandard
))
2101 return ANTIALIASED_QUALITY
;
2102 else if (EQ (type
, Qsubpixel
))
2103 return CLEARTYPE_QUALITY
;
2104 else if (EQ (type
, Qnatural
))
2105 return CLEARTYPE_NATURAL_QUALITY
;
2107 return DEFAULT_QUALITY
;
2110 /* Return a list of all the scripts that the font supports. */
2112 font_supported_scripts (FONTSIGNATURE
* sig
)
2114 DWORD
* subranges
= sig
->fsUsb
;
2115 Lisp_Object supported
= Qnil
;
2117 /* Match a single subrange. SYM is set if bit N is set in subranges. */
2118 #define SUBRANGE(n,sym) \
2119 if (subranges[(n) / 32] & (1 << ((n) % 32))) \
2120 supported = Fcons ((sym), supported)
2122 /* Match multiple subranges. SYM is set if any MASK bit is set in
2123 subranges[0 - 3]. */
2124 #define MASK_ANY(mask0,mask1,mask2,mask3,sym) \
2125 if ((subranges[0] & (mask0)) || (subranges[1] & (mask1)) \
2126 || (subranges[2] & (mask2)) || (subranges[3] & (mask3))) \
2127 supported = Fcons ((sym), supported)
2129 SUBRANGE (0, Qlatin
);
2130 /* 1: Latin-1 supplement, 2: Latin Extended A, 3: Latin Extended B. */
2131 /* Most fonts that support Latin will have good coverage of the
2132 Extended blocks, so in practice marking them below is not really
2133 needed, or useful: if a font claims support for, say, Latin
2134 Extended-B, but does not contain glyphs for some of the
2135 characters in the range, the user will have to augment her
2136 fontset to display those few characters. But we mark these
2137 subranges here anyway, for the marginal use cases where they
2138 might make a difference. */
2139 SUBRANGE (1, Qlatin
);
2140 SUBRANGE (2, Qlatin
);
2141 SUBRANGE (3, Qlatin
);
2142 SUBRANGE (4, Qphonetic
);
2143 /* 5: Spacing and tone modifiers, 6: Combining Diacritical Marks. */
2144 SUBRANGE (7, Qgreek
);
2145 SUBRANGE (8, Qcoptic
);
2146 SUBRANGE (9, Qcyrillic
);
2147 SUBRANGE (10, Qarmenian
);
2148 SUBRANGE (11, Qhebrew
);
2149 /* Bit 12 is rather useless if the user has Hebrew fonts installed,
2150 because apparently at some point in the past bit 12 was "Hebrew
2151 Extended", and many Hebrew fonts still have this bit set. The
2152 only workaround is to customize fontsets to use fonts like Ebrima
2154 SUBRANGE (12, Qvai
);
2155 SUBRANGE (13, Qarabic
);
2156 SUBRANGE (14, Qnko
);
2157 SUBRANGE (15, Qdevanagari
);
2158 SUBRANGE (16, Qbengali
);
2159 SUBRANGE (17, Qgurmukhi
);
2160 SUBRANGE (18, Qgujarati
);
2161 SUBRANGE (19, Qoriya
);
2162 SUBRANGE (20, Qtamil
);
2163 SUBRANGE (21, Qtelugu
);
2164 SUBRANGE (22, Qkannada
);
2165 SUBRANGE (23, Qmalayalam
);
2166 SUBRANGE (24, Qthai
);
2167 SUBRANGE (25, Qlao
);
2168 SUBRANGE (26, Qgeorgian
);
2169 SUBRANGE (27, Qbalinese
);
2170 /* 28: Hangul Jamo -- covered by the default fontset. */
2171 /* 29: Latin Extended, 30: Greek Extended -- covered above. */
2172 /* 31: Supplemental Punctuation -- most probably be masked by
2173 Courier New, so fontset customization is needed. */
2174 SUBRANGE (31, Qsymbol
);
2175 /* 32-47: Symbols (defined below). */
2176 SUBRANGE (48, Qcjk_misc
);
2177 /* Match either 49: katakana or 50: hiragana for kana. */
2178 MASK_ANY (0, 0x00060000, 0, 0, Qkana
);
2179 SUBRANGE (51, Qbopomofo
);
2180 /* 52: Compatibility Jamo */
2181 SUBRANGE (53, Qphags_pa
);
2182 /* 54: Enclosed CJK letters and months, 55: CJK Compatibility. */
2183 SUBRANGE (56, Qhangul
);
2184 /* 57: Surrogates. */
2185 SUBRANGE (58, Qphoenician
);
2186 SUBRANGE (59, Qhan
); /* There are others, but this is the main one. */
2187 SUBRANGE (59, Qideographic_description
); /* Windows lumps this in. */
2188 SUBRANGE (59, Qkanbun
); /* And this. */
2189 /* These are covered well either by the default Courier New or by
2190 CJK fonts that are set up specially in the default fontset. So
2191 marking them here wouldn't be useful. */
2192 /* 60: Private use, 61: CJK strokes and compatibility. */
2193 /* 62: Alphabetic Presentation, 63: Arabic Presentation A. */
2194 /* 64: Combining half marks, 65: Vertical and CJK compatibility. */
2195 /* 66: Small forms, 67: Arabic Presentation B, 68: Half and Full width. */
2197 SUBRANGE (70, Qtibetan
);
2198 SUBRANGE (71, Qsyriac
);
2199 SUBRANGE (72, Qthaana
);
2200 SUBRANGE (73, Qsinhala
);
2201 SUBRANGE (74, Qmyanmar
);
2202 SUBRANGE (75, Qethiopic
);
2203 SUBRANGE (76, Qcherokee
);
2204 SUBRANGE (77, Qcanadian_aboriginal
);
2205 SUBRANGE (78, Qogham
);
2206 SUBRANGE (79, Qrunic
);
2207 SUBRANGE (80, Qkhmer
);
2208 SUBRANGE (81, Qmongolian
);
2209 SUBRANGE (82, Qbraille
);
2211 SUBRANGE (84, Qbuhid
);
2212 SUBRANGE (84, Qhanunoo
);
2213 SUBRANGE (84, Qtagalog
);
2214 SUBRANGE (84, Qtagbanwa
);
2215 SUBRANGE (85, Qold_italic
);
2216 SUBRANGE (86, Qgothic
);
2217 SUBRANGE (87, Qdeseret
);
2218 SUBRANGE (88, Qbyzantine_musical_symbol
);
2219 SUBRANGE (88, Qmusical_symbol
); /* Windows doesn't distinguish these. */
2220 SUBRANGE (89, Qmathematical_bold
); /* See fontset.el:setup-default-fontset. */
2221 SUBRANGE (89, Qmathematical_italic
);
2222 SUBRANGE (89, Qmathematical_bold_italic
);
2223 SUBRANGE (89, Qmathematical_script
);
2224 SUBRANGE (89, Qmathematical_bold_script
);
2225 SUBRANGE (89, Qmathematical_fraktur
);
2226 SUBRANGE (89, Qmathematical_double_struck
);
2227 SUBRANGE (89, Qmathematical_bold_fraktur
);
2228 SUBRANGE (89, Qmathematical_sans_serif
);
2229 SUBRANGE (89, Qmathematical_sans_serif_bold
);
2230 SUBRANGE (89, Qmathematical_sans_serif_italic
);
2231 SUBRANGE (89, Qmathematical_sans_serif_bold_italic
);
2232 SUBRANGE (89, Qmathematical_monospace
);
2233 /* 90: Private use, 91: Variation selectors, 92: Tags. */
2234 SUBRANGE (93, Qlimbu
);
2235 SUBRANGE (94, Qtai_le
);
2236 SUBRANGE (95, Qtai_le
);
2237 SUBRANGE (96, Qbuginese
);
2238 SUBRANGE (97, Qglagolitic
);
2239 SUBRANGE (98, Qtifinagh
);
2240 /* 99: Yijing Hexagrams. */
2241 SUBRANGE (99, Qhan
);
2242 SUBRANGE (100, Qsyloti_nagri
);
2243 SUBRANGE (101, Qlinear_b
);
2244 SUBRANGE (102, Qancient_greek_number
);
2245 SUBRANGE (103, Qugaritic
);
2246 SUBRANGE (104, Qold_persian
);
2247 SUBRANGE (105, Qshavian
);
2248 SUBRANGE (106, Qosmanya
);
2249 SUBRANGE (107, Qcypriot
);
2250 SUBRANGE (108, Qkharoshthi
);
2251 SUBRANGE (109, Qtai_xuan_jing_symbol
);
2252 SUBRANGE (110, Qcuneiform
);
2253 SUBRANGE (111, Qcounting_rod_numeral
);
2254 SUBRANGE (112, Qsundanese
);
2255 SUBRANGE (113, Qlepcha
);
2256 SUBRANGE (114, Qol_chiki
);
2257 SUBRANGE (115, Qsaurashtra
);
2258 SUBRANGE (116, Qkayah_li
);
2259 SUBRANGE (117, Qrejang
);
2260 SUBRANGE (118, Qcham
);
2261 SUBRANGE (119, Qancient_symbol
);
2262 SUBRANGE (120, Qphaistos_disc
);
2263 SUBRANGE (121, Qlycian
);
2264 SUBRANGE (121, Qcarian
);
2265 SUBRANGE (121, Qlydian
);
2266 SUBRANGE (122, Qdomino_tile
);
2267 SUBRANGE (122, Qmahjong_tile
);
2268 /* 123-127: Reserved. */
2270 /* There isn't really a main symbol range, so include symbol if any
2271 relevant range is set. */
2272 MASK_ANY (0x8000000, 0x0000FFFF, 0, 0, Qsymbol
);
2274 /* Missing: Tai Viet (U+AA80-U+AADF). */
2281 /* Generate a full name for a Windows font.
2282 The full name is in fcname format, with weight, slant and antialiasing
2283 specified if they are not "normal". */
2285 w32font_full_name (LOGFONT
* font
, Lisp_Object font_obj
,
2286 int pixel_size
, char *name
, int nbytes
)
2288 int len
, height
, outline
;
2290 Lisp_Object antialiasing
, weight
= Qnil
;
2292 len
= strlen (font
->lfFaceName
);
2294 outline
= EQ (AREF (font_obj
, FONT_FOUNDRY_INDEX
), Qoutline
);
2296 /* Represent size of scalable fonts by point size. But use pixelsize for
2297 raster fonts to indicate that they are exactly that size. */
2299 len
+= 11; /* -SIZE */
2304 len
+= 7; /* :italic */
2306 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2308 weight
= w32_to_fc_weight (font
->lfWeight
);
2309 len
+= 1 + SBYTES (SYMBOL_NAME (weight
)); /* :WEIGHT */
2312 antialiasing
= lispy_antialias_type (font
->lfQuality
);
2313 if (! NILP (antialiasing
))
2314 len
+= 11 + SBYTES (SYMBOL_NAME (antialiasing
)); /* :antialias=NAME */
2316 /* Check that the buffer is big enough */
2321 p
+= sprintf (p
, "%s", font
->lfFaceName
);
2323 height
= font
->lfHeight
? eabs (font
->lfHeight
) : pixel_size
;
2329 float pointsize
= height
* 72.0 / one_w32_display_info
.resy
;
2330 /* Round to nearest half point. floor is used, since round is not
2331 supported in MS library. */
2332 pointsize
= floor (pointsize
* 2 + 0.5) / 2;
2333 p
+= sprintf (p
, "-%1.1f", pointsize
);
2336 p
+= sprintf (p
, ":pixelsize=%d", height
);
2339 if (SYMBOLP (weight
) && ! NILP (weight
))
2340 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2343 p
+= sprintf (p
, ":italic");
2345 if (SYMBOLP (antialiasing
) && ! NILP (antialiasing
))
2346 p
+= sprintf (p
, ":antialias=%s", SDATA (SYMBOL_NAME (antialiasing
)));
2351 /* Convert a logfont and point size into a fontconfig style font name.
2352 POINTSIZE is in tenths of points.
2353 If SIZE indicates the size of buffer FCNAME, into which the font name
2354 is written. If the buffer is not large enough to contain the name,
2355 the function returns -1, otherwise it returns the number of bytes
2356 written to FCNAME. */
2358 logfont_to_fcname (LOGFONT
* font
, int pointsize
, char *fcname
, int size
)
2362 Lisp_Object weight
= Qnil
;
2364 len
= strlen (font
->lfFaceName
) + 2;
2365 height
= pointsize
/ 10;
2366 while (height
/= 10)
2373 len
+= 7; /* :italic */
2374 if (font
->lfWeight
&& font
->lfWeight
!= FW_NORMAL
)
2376 weight
= w32_to_fc_weight (font
->lfWeight
);
2377 len
+= SBYTES (SYMBOL_NAME (weight
)) + 1;
2383 p
+= sprintf (p
, "%s-%d", font
->lfFaceName
, pointsize
/ 10);
2385 p
+= sprintf (p
, ".%d", pointsize
% 10);
2387 if (SYMBOLP (weight
) && !NILP (weight
))
2388 p
+= sprintf (p
, ":%s", SDATA (SYMBOL_NAME (weight
)));
2391 p
+= sprintf (p
, ":italic");
2393 return (p
- fcname
);
2397 compute_metrics (HDC dc
, struct w32font_info
*w32_font
, unsigned int code
,
2398 struct w32_metric_cache
*metrics
)
2402 unsigned int options
= GGO_METRICS
;
2405 if (w32_font
->glyph_idx
)
2406 options
|= GGO_GLYPH_INDEX
;
2408 memset (&transform
, 0, sizeof (transform
));
2409 transform
.eM11
.value
= 1;
2410 transform
.eM22
.value
= 1;
2412 if (get_glyph_outline_w (dc
, code
, options
, &gm
, 0, NULL
, &transform
)
2415 metrics
->lbearing
= gm
.gmptGlyphOrigin
.x
;
2416 metrics
->rbearing
= gm
.gmptGlyphOrigin
.x
+ gm
.gmBlackBoxX
;
2417 metrics
->width
= gm
.gmCellIncX
;
2418 metrics
->status
= W32METRIC_SUCCESS
;
2420 else if (get_char_width_32_w (dc
, code
, code
, &width
) != 0)
2422 metrics
->lbearing
= 0;
2423 metrics
->rbearing
= width
;
2424 metrics
->width
= width
;
2425 metrics
->status
= W32METRIC_SUCCESS
;
2428 metrics
->status
= W32METRIC_FAIL
;
2431 DEFUN ("x-select-font", Fx_select_font
, Sx_select_font
, 0, 2, 0,
2432 doc
: /* Read a font name using a W32 font selection dialog.
2433 Return fontconfig style font string corresponding to the selection.
2435 If FRAME is omitted or nil, it defaults to the selected frame.
2436 If EXCLUDE-PROPORTIONAL is non-nil, exclude proportional fonts
2437 in the font selection dialog. */)
2438 (Lisp_Object frame
, Lisp_Object exclude_proportional
)
2440 struct frame
*f
= decode_window_system_frame (frame
);
2448 memset (&cf
, 0, sizeof (cf
));
2449 memset (&lf
, 0, sizeof (lf
));
2451 cf
.lStructSize
= sizeof (cf
);
2452 cf
.hwndOwner
= FRAME_W32_WINDOW (f
);
2453 cf
.Flags
= CF_FORCEFONTEXIST
| CF_SCREENFONTS
| CF_NOVERTFONTS
;
2455 /* If exclude_proportional is non-nil, limit the selection to
2456 monospaced fonts. */
2457 if (!NILP (exclude_proportional
))
2458 cf
.Flags
|= CF_FIXEDPITCHONLY
;
2462 /* Initialize as much of the font details as we can from the current
2464 hdc
= GetDC (FRAME_W32_WINDOW (f
));
2465 oldobj
= SelectObject (hdc
, FONT_HANDLE (FRAME_FONT (f
)));
2466 GetTextFace (hdc
, LF_FACESIZE
, lf
.lfFaceName
);
2467 if (GetTextMetrics (hdc
, &tm
))
2469 lf
.lfHeight
= tm
.tmInternalLeading
- tm
.tmHeight
;
2470 lf
.lfWeight
= tm
.tmWeight
;
2471 lf
.lfItalic
= tm
.tmItalic
;
2472 lf
.lfUnderline
= tm
.tmUnderlined
;
2473 lf
.lfStrikeOut
= tm
.tmStruckOut
;
2474 lf
.lfCharSet
= tm
.tmCharSet
;
2475 cf
.Flags
|= CF_INITTOLOGFONTSTRUCT
;
2477 SelectObject (hdc
, oldobj
);
2478 ReleaseDC (FRAME_W32_WINDOW (f
), hdc
);
2480 if (!ChooseFont (&cf
)
2481 || logfont_to_fcname (&lf
, cf
.iPointSize
, buf
, 100) < 0)
2484 return DECODE_SYSTEM (build_string (buf
));
2487 static const char *const w32font_booleans
[] = {
2491 static const char *const w32font_non_booleans
[] = {
2499 w32font_filter_properties (Lisp_Object font
, Lisp_Object alist
)
2501 font_filter_properties (font
, alist
, w32font_booleans
, w32font_non_booleans
);
2504 struct font_driver w32font_driver
=
2506 LISP_INITIALLY_ZERO
, /* Qgdi */
2507 false, /* case insensitive */
2511 w32font_list_family
,
2512 NULL
, /* free_entity */
2515 NULL
, /* prepare_face */
2516 NULL
, /* done_face */
2518 w32font_encode_char
,
2519 w32font_text_extents
,
2521 NULL
, /* get_bitmap */
2522 NULL
, /* free_bitmap */
2523 NULL
, /* anchor_point */
2524 NULL
, /* otf_capability */
2525 NULL
, /* otf_drive */
2526 NULL
, /* start_for_frame */
2527 NULL
, /* end_for_frame */
2530 NULL
, /* get_variation_glyphs */
2531 w32font_filter_properties
,
2532 NULL
, /* cached_font_ok */
2536 /* Initialize state that does not change between invocations. This is only
2537 called when Emacs is dumped. */
2539 syms_of_w32font (void)
2541 DEFSYM (Qgdi
, "gdi");
2542 DEFSYM (Quniscribe
, "uniscribe");
2543 DEFSYM (QCformat
, ":format");
2545 /* Generic font families. */
2546 DEFSYM (Qmonospace
, "monospace");
2547 DEFSYM (Qserif
, "serif");
2548 DEFSYM (Qsansserif
, "sansserif");
2549 DEFSYM (Qscript
, "script");
2550 DEFSYM (Qdecorative
, "decorative");
2552 DEFSYM (Qsans_serif
, "sans_serif");
2553 DEFSYM (Qsans
, "sans");
2554 DEFSYM (Qmono
, "mono");
2556 /* Fake foundries. */
2557 DEFSYM (Qraster
, "raster");
2558 DEFSYM (Qoutline
, "outline");
2559 DEFSYM (Qunknown
, "unknown");
2562 DEFSYM (Qstandard
, "standard");
2563 DEFSYM (Qsubpixel
, "subpixel");
2564 DEFSYM (Qnatural
, "natural");
2570 DEFSYM (Qlatin
, "latin");
2571 DEFSYM (Qgreek
, "greek");
2572 DEFSYM (Qcoptic
, "coptic");
2573 DEFSYM (Qcyrillic
, "cyrillic");
2574 DEFSYM (Qarmenian
, "armenian");
2575 DEFSYM (Qhebrew
, "hebrew");
2576 DEFSYM (Qvai
, "vai");
2577 DEFSYM (Qarabic
, "arabic");
2578 DEFSYM (Qsyriac
, "syriac");
2579 DEFSYM (Qnko
, "nko");
2580 DEFSYM (Qthaana
, "thaana");
2581 DEFSYM (Qdevanagari
, "devanagari");
2582 DEFSYM (Qbengali
, "bengali");
2583 DEFSYM (Qgurmukhi
, "gurmukhi");
2584 DEFSYM (Qgujarati
, "gujarati");
2585 DEFSYM (Qoriya
, "oriya");
2586 DEFSYM (Qtamil
, "tamil");
2587 DEFSYM (Qtelugu
, "telugu");
2588 DEFSYM (Qkannada
, "kannada");
2589 DEFSYM (Qmalayalam
, "malayalam");
2590 DEFSYM (Qsinhala
, "sinhala");
2591 DEFSYM (Qthai
, "thai");
2592 DEFSYM (Qlao
, "lao");
2593 DEFSYM (Qtibetan
, "tibetan");
2594 DEFSYM (Qmyanmar
, "myanmar");
2595 DEFSYM (Qgeorgian
, "georgian");
2596 DEFSYM (Qhangul
, "hangul");
2597 DEFSYM (Qethiopic
, "ethiopic");
2598 DEFSYM (Qcherokee
, "cherokee");
2599 DEFSYM (Qcanadian_aboriginal
, "canadian-aboriginal");
2600 DEFSYM (Qogham
, "ogham");
2601 DEFSYM (Qrunic
, "runic");
2602 DEFSYM (Qkhmer
, "khmer");
2603 DEFSYM (Qmongolian
, "mongolian");
2604 DEFSYM (Qbraille
, "braille");
2605 DEFSYM (Qhan
, "han");
2606 DEFSYM (Qideographic_description
, "ideographic-description");
2607 DEFSYM (Qcjk_misc
, "cjk-misc");
2608 DEFSYM (Qkana
, "kana");
2609 DEFSYM (Qbopomofo
, "bopomofo");
2610 DEFSYM (Qkanbun
, "kanbun");
2612 DEFSYM (Qbyzantine_musical_symbol
, "byzantine-musical-symbol");
2613 DEFSYM (Qmusical_symbol
, "musical-symbol");
2614 DEFSYM (Qmathematical_bold
, "mathematical-bold");
2615 DEFSYM (Qmathematical_italic
, "mathematical-italic");
2616 DEFSYM (Qmathematical_bold_italic
, "mathematical-bold-italic");
2617 DEFSYM (Qmathematical_script
, "mathematical-script");
2618 DEFSYM (Qmathematical_bold_script
, "mathematical-bold-script");
2619 DEFSYM (Qmathematical_fraktur
, "mathematical-fraktur");
2620 DEFSYM (Qmathematical_double_struck
, "mathematical-double-struck");
2621 DEFSYM (Qmathematical_bold_fraktur
, "mathematical-bold-fraktur");
2622 DEFSYM (Qmathematical_sans_serif
, "mathematical-sans-serif");
2623 DEFSYM (Qmathematical_sans_serif_bold
, "mathematical-sans-serif-bold");
2624 DEFSYM (Qmathematical_sans_serif_italic
, "mathematical-sans-serif-italic");
2625 DEFSYM (Qmathematical_sans_serif_bold_italic
, "mathematical-sans-serif-bold-italic");
2626 DEFSYM (Qmathematical_monospace
, "mathematical-monospace");
2627 DEFSYM (Qcham
, "cham");
2628 DEFSYM (Qphonetic
, "phonetic");
2629 DEFSYM (Qbalinese
, "balinese");
2630 DEFSYM (Qbuginese
, "buginese");
2631 DEFSYM (Qbuhid
, "buhid");
2632 DEFSYM (Qcuneiform
, "cuneiform");
2633 DEFSYM (Qcypriot
, "cypriot");
2634 DEFSYM (Qdeseret
, "deseret");
2635 DEFSYM (Qglagolitic
, "glagolitic");
2636 DEFSYM (Qgothic
, "gothic");
2637 DEFSYM (Qhanunoo
, "hanunoo");
2638 DEFSYM (Qkharoshthi
, "kharoshthi");
2639 DEFSYM (Qlimbu
, "limbu");
2640 DEFSYM (Qlinear_b
, "linear_b");
2641 DEFSYM (Qold_italic
, "old_italic");
2642 DEFSYM (Qold_persian
, "old_persian");
2643 DEFSYM (Qosmanya
, "osmanya");
2644 DEFSYM (Qphags_pa
, "phags-pa");
2645 DEFSYM (Qphoenician
, "phoenician");
2646 DEFSYM (Qshavian
, "shavian");
2647 DEFSYM (Qsyloti_nagri
, "syloti_nagri");
2648 DEFSYM (Qtagalog
, "tagalog");
2649 DEFSYM (Qtagbanwa
, "tagbanwa");
2650 DEFSYM (Qtai_le
, "tai_le");
2651 DEFSYM (Qtifinagh
, "tifinagh");
2652 DEFSYM (Qugaritic
, "ugaritic");
2653 DEFSYM (Qlycian
, "lycian");
2654 DEFSYM (Qcarian
, "carian");
2655 DEFSYM (Qlydian
, "lydian");
2656 DEFSYM (Qdomino_tile
, "domino-tile");
2657 DEFSYM (Qmahjong_tile
, "mahjong-tile");
2658 DEFSYM (Qtai_xuan_jing_symbol
, "tai-xuan-jing-symbol");
2659 DEFSYM (Qcounting_rod_numeral
, "counting-rod-numeral");
2660 DEFSYM (Qancient_symbol
, "ancient-symbol");
2661 DEFSYM (Qphaistos_disc
, "phaistos-disc");
2662 DEFSYM (Qancient_greek_number
, "ancient-greek-number");
2663 DEFSYM (Qsundanese
, "sundanese");
2664 DEFSYM (Qlepcha
, "lepcha");
2665 DEFSYM (Qol_chiki
, "ol-chiki");
2666 DEFSYM (Qsaurashtra
, "saurashtra");
2667 DEFSYM (Qkayah_li
, "kayah-li");
2668 DEFSYM (Qrejang
, "rejang");
2670 /* W32 font encodings. */
2671 DEFVAR_LISP ("w32-charset-info-alist",
2672 Vw32_charset_info_alist
,
2673 doc
: /* Alist linking Emacs character sets to Windows fonts and codepages.
2674 Each entry should be of the form:
2676 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))
2678 where CHARSET_NAME is a string used in font names to identify the charset,
2679 WINDOWS_CHARSET is a symbol that can be one of:
2681 w32-charset-ansi, w32-charset-default, w32-charset-symbol,
2682 w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312,
2683 w32-charset-chinesebig5, w32-charset-johab, w32-charset-hebrew,
2684 w32-charset-arabic, w32-charset-greek, w32-charset-turkish,
2685 w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,
2686 w32-charset-russian, w32-charset-mac, w32-charset-baltic,
2689 CODEPAGE should be an integer specifying the codepage that should be used
2690 to display the character set, t to do no translation and output as Unicode,
2691 or nil to do no translation and output as 8 bit (or multibyte on far-east
2692 versions of Windows) characters. */);
2693 Vw32_charset_info_alist
= Qnil
;
2695 DEFSYM (Qw32_charset_ansi
, "w32-charset-ansi");
2696 DEFSYM (Qw32_charset_symbol
, "w32-charset-symbol");
2697 DEFSYM (Qw32_charset_default
, "w32-charset-default");
2698 DEFSYM (Qw32_charset_shiftjis
, "w32-charset-shiftjis");
2699 DEFSYM (Qw32_charset_hangeul
, "w32-charset-hangeul");
2700 DEFSYM (Qw32_charset_chinesebig5
, "w32-charset-chinesebig5");
2701 DEFSYM (Qw32_charset_gb2312
, "w32-charset-gb2312");
2702 DEFSYM (Qw32_charset_oem
, "w32-charset-oem");
2703 DEFSYM (Qw32_charset_johab
, "w32-charset-johab");
2704 DEFSYM (Qw32_charset_easteurope
, "w32-charset-easteurope");
2705 DEFSYM (Qw32_charset_turkish
, "w32-charset-turkish");
2706 DEFSYM (Qw32_charset_baltic
, "w32-charset-baltic");
2707 DEFSYM (Qw32_charset_russian
, "w32-charset-russian");
2708 DEFSYM (Qw32_charset_arabic
, "w32-charset-arabic");
2709 DEFSYM (Qw32_charset_greek
, "w32-charset-greek");
2710 DEFSYM (Qw32_charset_hebrew
, "w32-charset-hebrew");
2711 DEFSYM (Qw32_charset_vietnamese
, "w32-charset-vietnamese");
2712 DEFSYM (Qw32_charset_thai
, "w32-charset-thai");
2713 DEFSYM (Qw32_charset_mac
, "w32-charset-mac");
2715 defsubr (&Sx_select_font
);
2717 w32font_driver
.type
= Qgdi
;
2718 register_font_driver (&w32font_driver
, NULL
);
2722 globals_of_w32font (void)
2725 g_b_init_get_outline_metrics_w
= 0;
2726 g_b_init_get_text_metrics_w
= 0;
2727 g_b_init_get_glyph_outline_w
= 0;
2728 g_b_init_get_char_width_32_w
= 0;