w32font.c 86.6 KB
Newer Older
1
/* Font backend for the Microsoft Windows API.
Paul Eggert's avatar
Paul Eggert committed
2
   Copyright (C) 2007-2015 Free Software Foundation, Inc.
Jason Rumney's avatar
Jason Rumney committed
3 4 5

This file is part of GNU Emacs.

6
GNU Emacs is free software: you can redistribute it and/or modify
Jason Rumney's avatar
Jason Rumney committed
7
it under the terms of the GNU General Public License as published by
8 9
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jason Rumney's avatar
Jason Rumney committed
10 11 12 13 14 15 16

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

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/>.  */
Jason Rumney's avatar
Jason Rumney committed
18 19 20

#include <config.h>
#include <windows.h>
Daniel Colascione's avatar
Daniel Colascione committed
21
#include <stdio.h>
Juanma Barranquero's avatar
Juanma Barranquero committed
22
#include <math.h>
Juanma Barranquero's avatar
Juanma Barranquero committed
23
#include <ctype.h>
24
#include <commdlg.h>
Jason Rumney's avatar
Jason Rumney committed
25 26 27 28 29 30 31

#include "lisp.h"
#include "w32term.h"
#include "frame.h"
#include "dispextern.h"
#include "character.h"
#include "charset.h"
32
#include "coding.h"
Jason Rumney's avatar
Jason Rumney committed
33 34
#include "fontset.h"
#include "font.h"
Jason Rumney's avatar
Jason Rumney committed
35
#include "w32font.h"
36 37 38
#ifdef WINDOWSNT
#include "w32.h"
#endif
Jason Rumney's avatar
Jason Rumney committed
39

40 41 42 43 44 45 46 47 48 49 50
/* Cleartype available on Windows XP, cleartype_natural from XP SP1.
   The latter does not try to fit cleartype smoothed fonts into the
   same bounding box as the non-antialiased version of the font.
 */
#ifndef CLEARTYPE_QUALITY
#define CLEARTYPE_QUALITY 5
#endif
#ifndef CLEARTYPE_NATURAL_QUALITY
#define CLEARTYPE_NATURAL_QUALITY 6
#endif

51 52 53 54 55 56 57 58 59
/* VIETNAMESE_CHARSET and JOHAB_CHARSET are not defined in some versions
   of MSVC headers.  */
#ifndef VIETNAMESE_CHARSET
#define VIETNAMESE_CHARSET 163
#endif
#ifndef JOHAB_CHARSET
#define JOHAB_CHARSET 130
#endif

Dmitry Antipov's avatar
Dmitry Antipov committed
60
static void fill_in_logfont (struct frame *, LOGFONT *, Lisp_Object);
Jason Rumney's avatar
Jason Rumney committed
61

62 63
static BYTE w32_antialias_type (Lisp_Object);
static Lisp_Object lispy_antialias_type (BYTE);
64

65 66 67 68
static Lisp_Object font_supported_scripts (FONTSIGNATURE *);
static int w32font_full_name (LOGFONT *, Lisp_Object, int, char *, int);
static void compute_metrics (HDC, struct w32font_info *, unsigned int,
                             struct w32_metric_cache *);
Jason Rumney's avatar
Jason Rumney committed
69

70
static Lisp_Object w32_registry (LONG, DWORD);
Jason Rumney's avatar
Jason Rumney committed
71 72

/* EnumFontFamiliesEx callbacks.  */
73 74 75 76 77 78 79 80 81
static int CALLBACK ALIGN_STACK add_font_entity_to_list (ENUMLOGFONTEX *,
							 NEWTEXTMETRICEX *,
							 DWORD, LPARAM);
static int CALLBACK ALIGN_STACK add_one_font_entity_to_list (ENUMLOGFONTEX *,
							     NEWTEXTMETRICEX *,
							     DWORD, LPARAM);
static int CALLBACK ALIGN_STACK add_font_name_to_list (ENUMLOGFONTEX *,
						       NEWTEXTMETRICEX *,
						       DWORD, LPARAM);
Jason Rumney's avatar
Jason Rumney committed
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96
/* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
   of what we really want.  */
struct font_callback_data
{
  /* The logfont we are matching against. EnumFontFamiliesEx only matches
     face name and charset, so we need to manually match everything else
     in the callback function.  */
  LOGFONT pattern;
  /* The original font spec or entity.  */
  Lisp_Object orig_font_spec;
  /* The frame the font is being loaded on.  */
  Lisp_Object frame;
  /* The list to add matches to.  */
  Lisp_Object list;
Jason Rumney's avatar
Jason Rumney committed
97
  /* Whether to match only opentype fonts.  */
98
  bool opentype_only;
99 100 101 102
};

/* Handles the problem that EnumFontFamiliesEx will not return all
   style variations if the font name is not specified.  */
103
static void list_all_matching_fonts (struct font_callback_data *);
104

105 106
#ifdef WINDOWSNT

107 108 109 110
static BOOL g_b_init_get_outline_metrics_w;
static BOOL g_b_init_get_text_metrics_w;
static BOOL g_b_init_get_glyph_outline_w;
static BOOL g_b_init_get_glyph_outline_w;
111
static BOOL g_b_init_get_char_width_32_w;
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

typedef UINT (WINAPI * GetOutlineTextMetricsW_Proc) (
   HDC hdc,
   UINT cbData,
   LPOUTLINETEXTMETRICW lpotmw);
typedef BOOL (WINAPI * GetTextMetricsW_Proc) (
   HDC hdc,
   LPTEXTMETRICW lptmw);
typedef DWORD (WINAPI * GetGlyphOutlineW_Proc) (
   HDC hdc,
   UINT uChar,
   UINT uFormat,
   LPGLYPHMETRICS lpgm,
   DWORD cbBuffer,
   LPVOID lpvBuffer,
   const MAT2 *lpmat2);
128 129 130 131 132
typedef BOOL (WINAPI * GetCharWidth32W_Proc) (
   HDC hdc,
   UINT uFirstChar,
   UINT uLastChar,
   LPINT lpBuffer);
133 134 135 136 137 138 139 140 141 142 143 144

/* Several "wide" functions we use to support the font backends are
   unavailable on Windows 9X, unless UNICOWS.DLL is installed (their
   versions in the default libraries are non-functional stubs).  On NT
   and later systems, these functions are in GDI32.DLL.  The following
   helper function attempts to load UNICOWS.DLL on Windows 9X, and
   refuses to let Emacs start up if that library is not found.  On NT
   and later versions, it simply loads GDI32.DLL, which should always
   be available.  */
static HMODULE
w32_load_unicows_or_gdi32 (void)
{
145
  return maybe_load_unicows_dll ();
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
}

/* The following 3 functions call the problematic "wide" APIs via
   function pointers, to avoid linking against the non-standard
   libunicows on W9X.  */
static UINT WINAPI
get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw)
{
  static GetOutlineTextMetricsW_Proc s_pfn_Get_Outline_Text_MetricsW = NULL;
  HMODULE hm_unicows = NULL;
  if (g_b_init_get_outline_metrics_w == 0)
    {
      g_b_init_get_outline_metrics_w = 1;
      hm_unicows = w32_load_unicows_or_gdi32 ();
      if (hm_unicows)
	s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
	  GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
    }
164
  eassert (s_pfn_Get_Outline_Text_MetricsW != NULL);
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
  return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
}

static BOOL WINAPI
get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw)
{
  static GetTextMetricsW_Proc s_pfn_Get_Text_MetricsW = NULL;
  HMODULE hm_unicows = NULL;
  if (g_b_init_get_text_metrics_w == 0)
    {
      g_b_init_get_text_metrics_w = 1;
      hm_unicows = w32_load_unicows_or_gdi32 ();
      if (hm_unicows)
	s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
	  GetProcAddress (hm_unicows, "GetTextMetricsW");
    }
181
  eassert (s_pfn_Get_Text_MetricsW != NULL);
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
  return s_pfn_Get_Text_MetricsW (hdc, lptmw);
}

static DWORD WINAPI
get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm,
		     DWORD cbBuffer, LPVOID lpvBuffer, const MAT2 *lpmat2)
{
  static GetGlyphOutlineW_Proc s_pfn_Get_Glyph_OutlineW = NULL;
  HMODULE hm_unicows = NULL;
  if (g_b_init_get_glyph_outline_w == 0)
    {
      g_b_init_get_glyph_outline_w = 1;
      hm_unicows = w32_load_unicows_or_gdi32 ();
      if (hm_unicows)
	s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
	  GetProcAddress (hm_unicows, "GetGlyphOutlineW");
    }
199
  eassert (s_pfn_Get_Glyph_OutlineW != NULL);
200 201 202
  return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
				   lpvBuffer, lpmat2);
}
Jason Rumney's avatar
Jason Rumney committed
203

204 205
static DWORD WINAPI
get_char_width_32_w (HDC hdc, UINT uFirstChar, UINT uLastChar, LPINT lpBuffer)
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
{
  static GetCharWidth32W_Proc s_pfn_Get_Char_Width_32W = NULL;
  HMODULE hm_unicows = NULL;
  if (g_b_init_get_char_width_32_w == 0)
    {
      g_b_init_get_char_width_32_w = 1;
      hm_unicows = w32_load_unicows_or_gdi32 ();
      if (hm_unicows)
	s_pfn_Get_Char_Width_32W = (GetCharWidth32W_Proc)
	  GetProcAddress (hm_unicows, "GetCharWidth32W");
    }
  eassert (s_pfn_Get_Char_Width_32W != NULL);
  return s_pfn_Get_Char_Width_32W (hdc, uFirstChar, uLastChar, lpBuffer);
}

221 222 223 224 225 226 227 228 229 230 231 232
#else  /* Cygwin */

/* Cygwin doesn't support Windows 9X, and links against GDI32.DLL, so
   it can just call these functions directly.  */
#define get_outline_metrics_w(h,d,o)   GetOutlineTextMetricsW(h,d,o)
#define get_text_metrics_w(h,t)        GetTextMetricsW(h,t)
#define get_glyph_outline_w(h,uc,f,gm,b,v,m) \
                                       GetGlyphOutlineW(h,uc,f,gm,b,v,m)
#define get_char_width_32_w(h,fc,lc,b) GetCharWidth32W(h,fc,lc,b)

#endif	/* Cygwin */

Jason Rumney's avatar
Jason Rumney committed
233
static int
234
memq_no_quit (Lisp_Object elt, Lisp_Object list)
Jason Rumney's avatar
Jason Rumney committed
235 236 237 238 239 240
{
  while (CONSP (list) && ! EQ (XCAR (list), elt))
    list = XCDR (list);
  return (CONSP (list));
}

241
Lisp_Object
242
intern_font_name (char * string)
243
{
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);
250 251
}

Jason Rumney's avatar
Jason Rumney committed
252 253 254
/* w32 implementation of get_cache for font backend.
   Return a cache of font-entities on FRAME.  The cache must be a
   cons whose cdr part is the actual cache area.  */
Jason Rumney's avatar
Jason Rumney committed
255
Lisp_Object
Dmitry Antipov's avatar
Dmitry Antipov committed
256
w32font_get_cache (struct frame *f)
Jason Rumney's avatar
Jason Rumney committed
257
{
258
  struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
Jason Rumney's avatar
Jason Rumney committed
259 260 261 262 263 264 265 266

  return (dpyinfo->name_list_element);
}

/* w32 implementation of list for font backend.
   List fonts exactly matching with FONT_SPEC on FRAME.  The value
   is a vector of font-entities.  This is the sole API that
   allocates font-entities.  */
267
static Lisp_Object
268
w32font_list (struct frame *f, Lisp_Object font_spec)
Jason Rumney's avatar
Jason Rumney committed
269
{
270
  Lisp_Object fonts = w32font_list_internal (f, font_spec, 0);
271
  FONT_ADD_LOG ("w32font-list", font_spec, fonts);
272
  return fonts;
Jason Rumney's avatar
Jason Rumney committed
273 274 275 276
}

/* w32 implementation of match for font backend.
   Return a font entity most closely matching with FONT_SPEC on
Paul Eggert's avatar
Paul Eggert committed
277
   FRAME.  The closeness is determined by the font backend, thus
Jason Rumney's avatar
Jason Rumney committed
278
   `face-font-selection-order' is ignored here.  */
279
static Lisp_Object
280
w32font_match (struct frame *f, Lisp_Object font_spec)
Jason Rumney's avatar
Jason Rumney committed
281
{
282
  Lisp_Object entity = w32font_match_internal (f, font_spec, 0);
283
  FONT_ADD_LOG ("w32font-match", font_spec, entity);
284
  return entity;
Jason Rumney's avatar
Jason Rumney committed
285 286 287 288 289
}

/* w32 implementation of list_family for font backend.
   List available families.  The value is a list of family names
   (symbols).  */
290
static Lisp_Object
291
w32font_list_family (struct frame *f)
Jason Rumney's avatar
Jason Rumney committed
292 293 294 295 296
{
  Lisp_Object list = Qnil;
  LOGFONT font_match_pattern;
  HDC dc;

297
  memset (&font_match_pattern, 0, sizeof (font_match_pattern));
298
  font_match_pattern.lfCharSet = DEFAULT_CHARSET;
Jason Rumney's avatar
Jason Rumney committed
299 300 301 302 303 304 305 306 307 308 309 310 311 312

  dc = get_frame_dc (f);

  EnumFontFamiliesEx (dc, &font_match_pattern,
                      (FONTENUMPROC) add_font_name_to_list,
                      (LPARAM) &list, 0);
  release_frame_dc (f, dc);

  return list;
}

/* w32 implementation of open for font backend.
   Open a font specified by FONT_ENTITY on frame F.
   If the font is scalable, open it with PIXEL_SIZE.  */
313
static Lisp_Object
Dmitry Antipov's avatar
Dmitry Antipov committed
314
w32font_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
Jason Rumney's avatar
Jason Rumney committed
315
{
316 317 318 319 320
  Lisp_Object font_object
    = font_make_object (VECSIZE (struct w32font_info),
                        font_entity, pixel_size);
  struct w32font_info *w32_font
    = (struct w32font_info *) XFONT_OBJECT (font_object);
Jason Rumney's avatar
Jason Rumney committed
321

322
  ASET (font_object, FONT_TYPE_INDEX, Qgdi);
Jason Rumney's avatar
Jason Rumney committed
323

324
  if (!w32font_open_internal (f, font_entity, pixel_size, font_object))
Jason Rumney's avatar
Jason Rumney committed
325
    {
326
      return Qnil;
Jason Rumney's avatar
Jason Rumney committed
327 328
    }

329 330 331
  /* GDI backend does not use glyph indices.  */
  w32_font->glyph_idx = 0;

332
  return font_object;
Jason Rumney's avatar
Jason Rumney committed
333 334
}

335
/* w32 implementation of close for font_backend.  */
Jason Rumney's avatar
Jason Rumney committed
336
void
337
w32font_close (struct font *font)
Jason Rumney's avatar
Jason Rumney committed
338
{
339
  struct w32font_info *w32_font = (struct w32font_info *) font;
340

341
  if (w32_font->hfont)
342
    {
343 344 345 346 347 348 349
      /* Delete the GDI font object.  */
      DeleteObject (w32_font->hfont);
      w32_font->hfont = NULL;

      /* Free all the cached metrics.  */
      if (w32_font->cached_metrics)
	{
350 351
	  int i;

352 353 354 355 356
	  for (i = 0; i < w32_font->n_cache_blocks; i++)
	      xfree (w32_font->cached_metrics[i]);
	  xfree (w32_font->cached_metrics);
	  w32_font->cached_metrics = NULL;
	}
357
    }
Jason Rumney's avatar
Jason Rumney committed
358 359 360 361 362 363 364
}

/* w32 implementation of has_char for font backend.
   Optional.
   If FONT_ENTITY has a glyph for character C (Unicode code point),
   return 1.  If not, return 0.  If a font must be opened to check
   it, return -1.  */
Jason Rumney's avatar
Jason Rumney committed
365
int
366
w32font_has_char (Lisp_Object entity, int c)
Jason Rumney's avatar
Jason Rumney committed
367
{
368 369 370 371 372 373
  /* We can't be certain about which characters a font will support until
     we open it.  Checking the scripts that the font supports turns out
     to not be reliable.  */
  return -1;

#if 0
374
  Lisp_Object supported_scripts, extra, script;
Jason Rumney's avatar
Jason Rumney committed
375 376
  DWORD mask;

377 378 379 380
  extra = AREF (entity, FONT_EXTRA_INDEX);
  if (!CONSP (extra))
    return -1;

381
  supported_scripts = assq_no_quit (QCscript, extra);
382 383
  /* If font doesn't claim to support any scripts, then we can't be certain
     until we open it.  */
384
  if (!CONSP (supported_scripts))
Jason Rumney's avatar
Jason Rumney committed
385 386
    return -1;

387
  supported_scripts = XCDR (supported_scripts);
Jason Rumney's avatar
Jason Rumney committed
388

389
  script = CHAR_TABLE_REF (Vchar_script_table, c);
Jason Rumney's avatar
Jason Rumney committed
390

391 392 393 394 395 396 397 398
  /* If we don't know what script the character is from, then we can't be
     certain until we open it.  Also if the font claims support for the script
     the character is from, it may only have partial coverage, so we still
     can't be certain until we open the font.  */
  if (NILP (script) || memq_no_quit (script, supported_scripts))
    return -1;

  /* Font reports what scripts it supports, and none of them are the script
399 400 401 402 403
     the character is from. But we still can't be certain, as some fonts
     will contain some/most/all of the characters in that script without
     claiming support for it.  */
  return -1;
#endif
Jason Rumney's avatar
Jason Rumney committed
404 405 406
}

/* w32 implementation of encode_char for font backend.
407
   Return a glyph code of FONT for character C (Unicode code point).
408 409
   If FONT doesn't have such a glyph, return FONT_INVALID_CODE.

Juanma Barranquero's avatar
Juanma Barranquero committed
410
   For speed, the gdi backend uses Unicode (Emacs calls encode_char
411 412 413
   far too often for it to be efficient). But we still need to detect
   which characters are not supported by the font.
  */
414
static unsigned
415
w32font_encode_char (struct font *font, int c)
Jason Rumney's avatar
Jason Rumney committed
416
{
417
  struct w32font_info * w32_font = (struct w32font_info *)font;
418

419 420 421
  if (c < w32_font->metrics.tmFirstChar
      || c > w32_font->metrics.tmLastChar)
    return FONT_INVALID_CODE;
422
  else
423
    return c;
Jason Rumney's avatar
Jason Rumney committed
424 425 426 427 428
}

/* w32 implementation of text_extents for font backend.
   Perform the size computation of glyphs of FONT and fillin members
   of METRICS.  The glyphs are specified by their glyph codes in
429
   CODE (length NGLYPHS).  Apparently metrics can be NULL, in this
Jason Rumney's avatar
Jason Rumney committed
430
   case just return the overall width.  */
431
void
432 433
w32font_text_extents (struct font *font, unsigned *code,
		      int nglyphs, struct font_metrics *metrics)
Jason Rumney's avatar
Jason Rumney committed
434 435
{
  int i;
436 437
  HFONT old_font = NULL;
  HDC dc = NULL;
Jason Rumney's avatar
Jason Rumney committed
438
  struct frame * f;
Jason Rumney's avatar
Jason Rumney committed
439
  int total_width = 0;
440
  WORD *wcode;
441
  SIZE size;
442
  bool first;
Jason Rumney's avatar
Jason Rumney committed
443

444 445
  struct w32font_info *w32_font = (struct w32font_info *) font;

446
  memset (metrics, 0, sizeof (struct font_metrics));
Jason Rumney's avatar
Jason Rumney committed
447

448
  for (i = 0, first = true; i < nglyphs; i++)
449 450 451 452
    {
      struct w32_metric_cache *char_metric;
      int block = *(code + i) / CACHE_BLOCKSIZE;
      int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
Jason Rumney's avatar
Jason Rumney committed
453

454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
      if (block >= w32_font->n_cache_blocks)
	{
	  if (!w32_font->cached_metrics)
	    w32_font->cached_metrics
	      = xmalloc ((block + 1)
			 * sizeof (struct w32_metric_cache *));
	  else
	    w32_font->cached_metrics
	      = xrealloc (w32_font->cached_metrics,
			  (block + 1)
			  * sizeof (struct w32_metric_cache *));
	  memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0,
		  ((block + 1 - w32_font->n_cache_blocks)
		   * sizeof (struct w32_metric_cache *)));
	  w32_font->n_cache_blocks = block + 1;
	}
Jason Rumney's avatar
Jason Rumney committed
470

471 472 473 474 475
      if (!w32_font->cached_metrics[block])
	{
	  w32_font->cached_metrics[block]
	    = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
	}
Jason Rumney's avatar
Jason Rumney committed
476

477
      char_metric = w32_font->cached_metrics[block] + pos_in_block;
Jason Rumney's avatar
Jason Rumney committed
478

479 480 481
      if (char_metric->status == W32METRIC_NO_ATTEMPT)
	{
	  if (dc == NULL)
Jason Rumney's avatar
Jason Rumney committed
482
	    {
483 484 485 486 487 488 489 490
	      /* TODO: Frames can come and go, and their fonts
		 outlive them. So we can't cache the frame in the
		 font structure.  Use selected_frame until the API
		 is updated to pass in a frame.  */
	      f = XFRAME (selected_frame);

	      dc = get_frame_dc (f);
	      old_font = SelectObject (dc, w32_font->hfont);
Jason Rumney's avatar
Jason Rumney committed
491
	    }
492 493
	  compute_metrics (dc, w32_font, *(code + i), char_metric);
	}
494

495 496
      if (char_metric->status == W32METRIC_SUCCESS)
	{
497 498 499 500 501 502 503 504 505 506 507 508 509
	  if (first)
	    {
	      metrics->lbearing = char_metric->lbearing;
	      metrics->rbearing = char_metric->rbearing;
	      metrics->width    = 0;
	      metrics->ascent   = char_metric->ascent;
	      metrics->descent  = char_metric->descent;
	      first = false;
	    }
	  if (metrics->lbearing > char_metric->lbearing)
	    metrics->lbearing = char_metric->lbearing;
	  if (metrics->rbearing < char_metric->rbearing)
	    metrics->rbearing = char_metric->rbearing;
510
	  metrics->width += char_metric->width;
511 512 513 514
	  if (metrics->ascent < char_metric->ascent)
	    metrics->ascent = char_metric->ascent;
	  if (metrics->descent < char_metric->descent)
	    metrics->descent = char_metric->descent;
Jason Rumney's avatar
Jason Rumney committed
515
	}
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
      else
	/* If we couldn't get metrics for a char,
	   use alternative method.  */
	break;
    }
  /* If we got through everything, return.  */
  if (i == nglyphs)
    {
      if (dc != NULL)
	{
	  /* Restore state and release DC.  */
	  SelectObject (dc, old_font);
	  release_frame_dc (f, dc);
	}
      return;
Jason Rumney's avatar
Jason Rumney committed
531
    }
532

533 534 535
  /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
     fallback on other methods that will at least give some of the metric
     information.  */
536

537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
  /* Make array big enough to hold surrogates.  */
  wcode = alloca (nglyphs * sizeof (WORD) * 2);
  for (i = 0; i < nglyphs; i++)
    {
      if (code[i] < 0x10000)
        wcode[i] = code[i];
      else
        {
          DWORD surrogate = code[i] - 0x10000;

          /* High surrogate: U+D800 - U+DBFF.  */
          wcode[i++] = 0xD800 + ((surrogate >> 10) & 0x03FF);
          /* Low surrogate: U+DC00 - U+DFFF.  */
          wcode[i] = 0xDC00 + (surrogate & 0x03FF);
          /* An extra glyph. wcode is already double the size of code to
             cope with this.  */
          nglyphs++;
        }
    }

557 558
  if (dc == NULL)
    {
Jason Rumney's avatar
Jason Rumney committed
559 560 561 562 563 564
      /* TODO: Frames can come and go, and their fonts outlive
	 them. So we can't cache the frame in the font structure.  Use
	 selected_frame until the API is updated to pass in a
	 frame.  */
      f = XFRAME (selected_frame);

565
      dc = get_frame_dc (f);
566
      old_font = SelectObject (dc, w32_font->hfont);
567 568
    }

569
  if (GetTextExtentPoint32W (dc, wcode, nglyphs, &size))
Jason Rumney's avatar
Jason Rumney committed
570
    {
571
      total_width = size.cx;
Jason Rumney's avatar
Jason Rumney committed
572 573
    }

Juanma Barranquero's avatar
Juanma Barranquero committed
574
  /* On 95/98/ME, only some Unicode functions are available, so fallback
575
     on doing a dummy draw to find the total width.  */
576
  if (!total_width)
Jason Rumney's avatar
Jason Rumney committed
577 578
    {
      RECT rect;
579
      rect.top = 0; rect.bottom = font->height; rect.left = 0; rect.right = 1;
Jason Rumney's avatar
Jason Rumney committed
580 581 582 583
      DrawTextW (dc, wcode, nglyphs, &rect,
                 DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE);
      total_width = rect.right;
    }
584

585
  /* Give our best estimate of the metrics, based on what we know.  */
586 587 588
  metrics->width = total_width - w32_font->metrics.tmOverhang;
  metrics->lbearing = 0;
  metrics->rbearing = total_width;
589 590
  metrics->ascent = font->ascent;
  metrics->descent = font->descent;
591

Jason Rumney's avatar
Jason Rumney committed
592 593
  /* Restore state and release DC.  */
  SelectObject (dc, old_font);
Jason Rumney's avatar
Jason Rumney committed
594
  release_frame_dc (f, dc);
Jason Rumney's avatar
Jason Rumney committed
595 596 597 598 599
}

/* w32 implementation of draw for font backend.
   Optional.
   Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
600 601 602
   position of frame F with S->FACE and S->GC.  If WITH_BACKGROUND,
   fill the background in advance.  It is assured that WITH_BACKGROUND
   is false when (FROM > 0 || TO < S->nchars).
603 604 605 606 607 608 609

   TODO: Currently this assumes that the colors and fonts are already
   set in the DC. This seems to be true now, but maybe only due to
   the old font code setting it up. It may be safer to resolve faces
   and fonts in here and set them explicitly
*/

Jason Rumney's avatar
Jason Rumney committed
610
int
611
w32font_draw (struct glyph_string *s, int from, int to,
612
	      int x, int y, bool with_background)
Jason Rumney's avatar
Jason Rumney committed
613
{
614
  UINT options;
615
  HRGN orig_clip = NULL;
616
  int len = to - from;
617
  struct w32font_info *w32font = (struct w32font_info *) s->font;
618 619

  options = w32font->glyph_idx;
620 621 622 623 624

  if (s->num_clips > 0)
    {
      HRGN new_clip = CreateRectRgnIndirect (s->clip);

625 626
      /* Save clip region for later restoration.  */
      orig_clip = CreateRectRgn (0, 0, 0, 0);
627
      if (!GetClipRgn (s->hdc, orig_clip))
628 629 630 631 632
	{
	  DeleteObject (orig_clip);
	  orig_clip = NULL;
	}

633 634 635 636 637 638 639 640 641 642 643
      if (s->num_clips > 1)
        {
          HRGN clip2 = CreateRectRgnIndirect (s->clip + 1);

          CombineRgn (new_clip, new_clip, clip2, RGN_OR);
          DeleteObject (clip2);
        }

      SelectClipRgn (s->hdc, new_clip);
      DeleteObject (new_clip);
    }
Jason Rumney's avatar
Jason Rumney committed
644

645 646 647
  /* Using OPAQUE background mode can clear more background than expected
     when Cleartype is used.  Draw the background manually to avoid this.  */
  SetBkMode (s->hdc, TRANSPARENT);
Jason Rumney's avatar
Jason Rumney committed
648 649
  if (with_background)
    {
650 651
      HBRUSH brush;
      RECT rect;
652
      struct font *font = s->font;
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672
      int ascent = font->ascent, descent = font->descent;

      /* Font's global ascent and descent values might be
	 preposterously large for some fonts.  We fix here the case
	 when those fonts are used for display of glyphless
	 characters, because drawing background with font dimensions
	 in those cases makes the display illegible.  There's only one
	 more call to the draw method with with_background set to
	 true, and that's in x_draw_glyph_string_foreground, when
	 drawing the cursor, where we have no such heuristics
	 available.  FIXME.  */
      if (s->first_glyph->type == GLYPHLESS_GLYPH
	  && (s->first_glyph->u.glyphless.method == GLYPHLESS_DISPLAY_HEX_CODE
	      || s->first_glyph->u.glyphless.method == GLYPHLESS_DISPLAY_ACRONYM))
	{
	  ascent =
	    s->first_glyph->slice.glyphless.lower_yoff
	    - s->first_glyph->slice.glyphless.upper_yoff;
	  descent = 0;
	}
673 674
      brush = CreateSolidBrush (s->gc->background);
      rect.left = x;
675
      rect.top = y - ascent;
676
      rect.right = x + s->width;
677
      rect.bottom = y + descent;
678
      FillRect (s->hdc, &rect, brush);
679
      DeleteObject (brush);
Jason Rumney's avatar
Jason Rumney committed
680
    }
681

682 683
  if (s->padding_p)
    {
684
      int i;
685 686 687

      for (i = 0; i < len; i++)
	ExtTextOutW (s->hdc, x + i, y, options, NULL,
688
		     s->char2b + from + i, 1, NULL);
689 690
    }
  else
691
    ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
692 693 694

  /* Restore clip region.  */
  if (s->num_clips > 0)
695 696 697 698
    SelectClipRgn (s->hdc, orig_clip);

  if (orig_clip)
    DeleteObject (orig_clip);
699 700

  return len;
Jason Rumney's avatar
Jason Rumney committed
701 702 703 704 705
}

/* w32 implementation of free_entity for font backend.
   Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
   Free FONT_EXTRA_INDEX field of FONT_ENTITY.
706 707
static void
w32font_free_entity (Lisp_Object entity);
Jason Rumney's avatar
Jason Rumney committed
708 709 710 711 712 713 714
  */

/* w32 implementation of prepare_face for font backend.
   Optional (if FACE->extra is not used).
   Prepare FACE for displaying characters by FONT on frame F by
   storing some data in FACE->extra.  If successful, return 0.
   Otherwise, return -1.
715
static int
Dmitry Antipov's avatar
Dmitry Antipov committed
716
w32font_prepare_face (struct frame *f, struct face *face);
Jason Rumney's avatar
Jason Rumney committed
717 718 719 720
  */
/* w32 implementation of done_face for font backend.
   Optional.
   Done FACE for displaying characters by FACE->font on frame F.
721
static void
Dmitry Antipov's avatar
Dmitry Antipov committed
722
w32font_done_face (struct frame *f, struct face *face);  */
Jason Rumney's avatar
Jason Rumney committed
723 724 725 726

/* w32 implementation of get_bitmap for font backend.
   Optional.
   Store bitmap data for glyph-code CODE of FONT in BITMAP.  It is
727
   intended that this method is called from the other font-driver
Jason Rumney's avatar
Jason Rumney committed
728
   for actual drawing.
729 730 731
static int
w32font_get_bitmap (struct font *font, unsigned code,
                    struct font_bitmap *bitmap, int bits_per_pixel);
Jason Rumney's avatar
Jason Rumney committed
732 733 734 735
  */
/* w32 implementation of free_bitmap for font backend.
   Optional.
   Free bitmap data in BITMAP.
736 737
static void
w32font_free_bitmap (struct font *font, struct font_bitmap *bitmap);
Jason Rumney's avatar
Jason Rumney committed
738 739 740 741 742
  */
/* w32 implementation of anchor_point for font backend.
   Optional.
   Get coordinates of the INDEXth anchor point of the glyph whose
   code is CODE.  Store the coordinates in *X and *Y.  Return 0 if
Paul Eggert's avatar
Paul Eggert committed
743
   the operations was successful.  Otherwise return -1.
744 745
static int
w32font_anchor_point (struct font *font, unsigned code,
Jason Rumney's avatar
Jason Rumney committed
746 747 748 749 750 751
                                 int index, int *x, int *y);
  */
/* w32 implementation of otf_capability for font backend.
   Optional.
   Return a list describing which scripts/languages FONT
   supports by which GSUB/GPOS features of OpenType tables.
752 753
static Lisp_Object
w32font_otf_capability (struct font *font);
Jason Rumney's avatar
Jason Rumney committed
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
  */
/* w32 implementation of otf_drive for font backend.
   Optional.
   Apply FONT's OTF-FEATURES to the glyph string.

   FEATURES specifies which OTF features to apply in this format:
      (SCRIPT LANGSYS GSUB-FEATURE GPOS-FEATURE)
   See the documentation of `font-drive-otf' for the detail.

   This method applies the specified features to the codes in the
   elements of GSTRING-IN (between FROMth and TOth).  The output
   codes are stored in GSTRING-OUT at the IDXth element and the
   following elements.

   Return the number of output codes.  If none of the features are
   applicable to the input data, return 0.  If GSTRING-OUT is too
   short, return -1.
771 772 773 774
static int
w32font_otf_drive (struct font *font, Lisp_Object features,
                   Lisp_Object gstring_in, int from, int to,
                   Lisp_Object gstring_out, int idx,
775
                   bool alternate_subst);
Jason Rumney's avatar
Jason Rumney committed
776 777
  */

Jason Rumney's avatar
Jason Rumney committed
778 779 780 781
/* Internal implementation of w32font_list.
   Additional parameter opentype_only restricts the returned fonts to
   opentype fonts, which can be used with the Uniscribe backend.  */
Lisp_Object
782 783
w32font_list_internal (struct frame *f, Lisp_Object font_spec,
		       bool opentype_only)
Jason Rumney's avatar
Jason Rumney committed
784 785 786 787 788 789
{
  struct font_callback_data match_data;
  HDC dc;

  match_data.orig_font_spec = font_spec;
  match_data.list = Qnil;
790
  XSETFRAME (match_data.frame, f);
Jason Rumney's avatar
Jason Rumney committed
791

792
  memset (&match_data.pattern, 0, sizeof (LOGFONT));
Jason Rumney's avatar
Jason Rumney committed
793 794
  fill_in_logfont (f, &match_data.pattern, font_spec);

795 796 797 798 799 800 801 802 803 804 805 806 807
  /* If the charset is unrecognized, then we won't find a font, so don't
     waste time looking for one.  */
  if (match_data.pattern.lfCharSet == DEFAULT_CHARSET)
    {
      Lisp_Object spec_charset = AREF (font_spec, FONT_REGISTRY_INDEX);
      if (!NILP (spec_charset)
	  && !EQ (spec_charset, Qiso10646_1)
	  && !EQ (spec_charset, Qunicode_bmp)
	  && !EQ (spec_charset, Qunicode_sip)
	  && !EQ (spec_charset, Qunknown))
	return Qnil;
    }

Jason Rumney's avatar
Jason Rumney committed
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
  match_data.opentype_only = opentype_only;
  if (opentype_only)
    match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;

  if (match_data.pattern.lfFaceName[0] == '\0')
    {
      /* EnumFontFamiliesEx does not take other fields into account if
         font name is blank, so need to use two passes.  */
      list_all_matching_fonts (&match_data);
    }
  else
    {
      dc = get_frame_dc (f);

      EnumFontFamiliesEx (dc, &match_data.pattern,
                          (FONTENUMPROC) add_font_entity_to_list,
                          (LPARAM) &match_data, 0);
      release_frame_dc (f, dc);
    }

828
  return match_data.list;
Jason Rumney's avatar
Jason Rumney committed
829 830 831 832 833 834
}

/* Internal implementation of w32font_match.
   Additional parameter opentype_only restricts the returned fonts to
   opentype fonts, which can be used with the Uniscribe backend.  */
Lisp_Object
835 836
w32font_match_internal (struct frame *f, Lisp_Object font_spec,
			bool opentype_only)
Jason Rumney's avatar
Jason Rumney committed
837 838 839 840 841
{
  struct font_callback_data match_data;
  HDC dc;

  match_data.orig_font_spec = font_spec;
842
  XSETFRAME (match_data.frame, f);
Jason Rumney's avatar
Jason Rumney committed
843 844
  match_data.list = Qnil;

845
  memset (&match_data.pattern, 0, sizeof (LOGFONT));
Jason Rumney's avatar
Jason Rumney committed
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
  fill_in_logfont (f, &match_data.pattern, font_spec);

  match_data.opentype_only = opentype_only;
  if (opentype_only)
    match_data.pattern.lfOutPrecision = OUT_OUTLINE_PRECIS;

  dc = get_frame_dc (f);

  EnumFontFamiliesEx (dc, &match_data.pattern,
                      (FONTENUMPROC) add_one_font_entity_to_list,
                      (LPARAM) &match_data, 0);
  release_frame_dc (f, dc);

  return NILP (match_data.list) ? Qnil : XCAR (match_data.list);
}

862
int
Dmitry Antipov's avatar
Dmitry Antipov committed
863
w32font_open_internal (struct frame *f, Lisp_Object font_entity,
864
		       int pixel_size, Lisp_Object font_object)
865
{
866
  int len, size;
867 868 869
  LOGFONT logfont;
  HDC dc;
  HFONT hfont, old_font;
870
  Lisp_Object val;
871 872
  struct w32font_info *w32_font;
  struct font * font;
873
  OUTLINETEXTMETRICW* metrics = NULL;
874 875 876

  w32_font = (struct w32font_info *) XFONT_OBJECT (font_object);
  font = (struct font *) w32_font;
877 878 879 880

  if (!font)
    return 0;

881
  memset (&logfont, 0, sizeof (logfont));
882 883
  fill_in_logfont (f, &logfont, font_entity);

884 885 886 887 888 889
  /* Prefer truetype fonts, to avoid known problems with type1 fonts, and
     limitations in bitmap fonts.  */
  val = AREF (font_entity, FONT_FOUNDRY_INDEX);
  if (!EQ (val, Qraster))
    logfont.lfOutPrecision = OUT_TT_PRECIS;

890 891 892 893 894 895 896 897 898 899 900 901 902 903
  size = XINT (AREF (font_entity, FONT_SIZE_INDEX));
  if (!size)
    size = pixel_size;

  logfont.lfHeight = -size;
  hfont = CreateFontIndirect (&logfont);

  if (hfont == NULL)
    return 0;

  /* Get the metrics for this font.  */
  dc = get_frame_dc (f);
  old_font = SelectObject (dc, hfont);

904
  /* Try getting the outline metrics (only works for truetype fonts).  */
905
  len = get_outline_metrics_w (dc, 0, NULL);
906 907
  if (len)
    {
908
      metrics = (OUTLINETEXTMETRICW *) alloca (len);
909
      if (get_outline_metrics_w (dc, len, metrics))
910 911
        memcpy (&w32_font->metrics, &metrics->otmTextMetrics,
		sizeof (TEXTMETRICW));
912 913 914
      else
        metrics = NULL;
    }
915

916
  if (!metrics)
917
    get_text_metrics_w (dc, &w32_font->metrics);
918

Jason Rumney's avatar
Jason Rumney committed
919 920
  w32_font->cached_metrics = NULL;
  w32_font->n_cache_blocks = 0;
921

922 923
  SelectObject (dc, old_font);
  release_frame_dc (f, dc);
924

925
  w32_font->hfont = hfont;
926

927 928 929 930 931 932
  {
    char *name;

    /* We don't know how much space we need for the full name, so start with
       96 bytes and go up in steps of 32.  */
    len = 96;
933
    name = alloca (len);
934 935
    while (name && w32font_full_name (&logfont, font_entity, pixel_size,
                                      name, len) < 0)
936
      {
937 938
        len += 32;
        name = alloca (len);
939 940
      }
    if (name)
941
      font->props[FONT_FULLNAME_INDEX]
942
        = DECODE_SYSTEM (build_string (name));
943
    else
944 945
      font->props[FONT_FULLNAME_INDEX]
	= DECODE_SYSTEM (build_string (logfont.lfFaceName));
946
  }
947 948

  font->max_width = w32_font->metrics.tmMaxCharWidth;
949
  /* Parts of Emacs display assume that height = ascent + descent...
950
     so height is defined later, after ascent and descent.
951
  font->height = w32_font->metrics.tmHeight
952
    + w32_font->metrics.tmExternalLeading;
953 954
  */

955 956 957 958 959 960
  font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;

  font->vertical_centering = 0;
  font->baseline_offset = 0;
  font->relative_compose = 0;
  font->default_ascent = w32_font->metrics.tmAscent;
961 962 963 964
  font->pixel_size = size;
  font->driver = &w32font_driver;
  font->encoding_charset = -1;
  font->repertory_charset = -1;
965
  /* TODO: do we really want the minimum width here, which could be negative? */
966
  font->min_width = font->space_width;
967 968
  font->ascent = w32_font->metrics.tmAscent;
  font->descent = w32_font->metrics.tmDescent;
969
  font->height = font->ascent + font->descent;
970 971 972 973 974 975 976 977 978 979 980

  if (metrics)
    {
      font->underline_thickness = metrics->otmsUnderscoreSize;
      font->underline_position = -metrics->otmsUnderscorePosition;
    }
  else
    {
      font->underline_thickness = 0;
      font->underline_position = -1;
    }
981

982 983 984 985
  /* For temporary compatibility with legacy code that expects the
     name to be usable in x-list-fonts. Eventually we expect to change
     x-list-fonts and other places that use fonts so that this can be
     an fcname or similar.  */
Kenichi Handa's avatar
Kenichi Handa committed
986
  font->props[FONT_NAME_INDEX] = Ffont_xlfd_name (font_object, Qnil);
987

988 989 990
  return 1;
}

Jason Rumney's avatar
Jason Rumney committed
991 992
/* Callback function for EnumFontFamiliesEx.
 * Adds the name of a font to a Lisp list (passed in as the lParam arg).  */
993
static int CALLBACK ALIGN_STACK
994 995 996
add_font_name_to_list (ENUMLOGFONTEX *logical_font,
		       NEWTEXTMETRICEX *physical_font,
		       DWORD font_type, LPARAM list_object)
Jason Rumney's avatar
Jason Rumney committed
997 998
{
  Lisp_Object* list = (Lisp_Object *) list_object;
999 1000 1001 1002 1003 1004
  Lisp_Object family;

  /* Skip vertical fonts (intended only for printing)  */
  if (logical_font->elfLogFont.lfFaceName[0] == '@')
    return 1;

1005
  family = intern_font_name (logical_font->elfLogFont.lfFaceName);
Jason Rumney's avatar
Jason Rumney committed
1006 1007 1008 1009 1010 1011
  if (! memq_no_quit (family, *list))
    *list = Fcons (family, *list);

  return 1;
}

1012 1013
static int w32_decode_weight (int);
static int w32_encode_weight (int);
1014

Jason Rumney's avatar
Jason Rumney committed
1015
/* Convert an enumerated Windows font to an Emacs font entity.  */
1016
static Lisp_Object
1017 1018 1019 1020 1021 1022
w32_enumfont_pattern_entity (Lisp_Object frame,
			     ENUMLOGFONTEX *logical_font,
			     NEWTEXTMETRICEX *physical_font,
			     DWORD font_type,
			     LOGFONT *requested_font,
			     Lisp_Object backend)
Jason Rumney's avatar
Jason Rumney committed
1023 1024 1025 1026
{
  Lisp_Object entity, tem;
  LOGFONT *lf = (LOGFONT*) logical_font;
  BYTE generic_type;
1027
  DWORD full_type = physical_font->ntmTm.ntmFlags;
Jason Rumney's avatar
Jason Rumney committed
1028

1029
  entity = font_make_entity ();
Jason Rumney's avatar
Jason Rumney committed
1030

1031
  ASET (entity, FONT_TYPE_INDEX, backend);
1032
  ASET (entity, FONT_REGISTRY_INDEX, w32_registry (lf->lfCharSet, font_type));
Jason Rumney's avatar
Jason Rumney committed
1033 1034 1035
  ASET (entity, FONT_OBJLIST_INDEX, Qnil);

  /* Foundry is difficult to get in readable form on Windows.
1036
     But Emacs crashes if it is not set, so set it to something more
1037
     generic.  These values make xlfds compatible with Emacs 22. */
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
  if (lf->lfOutPrecision == OUT_STRING_PRECIS)
    tem = Qraster;
  else if (lf->lfOutPrecision == OUT_STROKE_PRECIS)
    tem = Qoutline;
  else
    tem = Qunknown;

  ASET (entity, FONT_FOUNDRY_INDEX, tem);

  /* Save the generic family in the extra info, as it is likely to be
     useful to users looking for a close match.  */
Jason Rumney's avatar
Jason Rumney committed
1049 1050 1051 1052
  generic_type = physical_font->ntmTm.tmPitchAndFamily & 0xF0;
  if (generic_type == FF_DECORATIVE)
    tem = Qdecorative;
  else if (generic_type == FF_MODERN)
1053
    tem = Qmono;
Jason Rumney's avatar
Jason Rumney committed
1054
  else if (generic_type == FF_ROMAN)
1055
    tem = Qserif;
Jason Rumney's avatar
Jason Rumney committed
1056 1057 1058
  else if (generic_type == FF_SCRIPT)
    tem = Qscript;
  else if (generic_type == FF_SWISS)
1059
    tem = Qsans;
Jason Rumney's avatar
Jason Rumney committed
1060
  else
1061
    tem = Qnil;
1062 1063

  ASET (entity, FONT_ADSTYLE_INDEX, tem);
Jason Rumney's avatar
Jason Rumney committed
1064

1065
  if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
1066
    ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_PROPORTIONAL));
1067
  else
1068
    ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_CHARCELL));
Jason Rumney's avatar
Jason Rumney committed
1069

1070 1071 1072 1073 1074
  if (requested_font->lfQuality != DEFAULT_QUALITY)
    {
      font_put_extra (entity, QCantialias,
                      lispy_antialias_type (requested_font->lfQuality));
    }
Jason Rumney's avatar
Jason Rumney committed
1075
  ASET (entity, FONT_FAMILY_INDEX,