/* Font backend for the Microsoft Windows API.
- Copyright (C) 2007-2013 Free Software Foundation, Inc.
+ Copyright (C) 2007-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include "fontset.h"
#include "font.h"
#include "w32font.h"
+#ifdef WINDOWSNT
+#include "w32.h"
+#endif
/* Cleartype available on Windows XP, cleartype_natural from XP SP1.
The latter does not try to fit cleartype smoothed fonts into the
style variations if the font name is not specified. */
static void list_all_matching_fonts (struct font_callback_data *);
-static BOOL g_b_init_is_w9x;
+#ifdef WINDOWSNT
+
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 HMODULE
w32_load_unicows_or_gdi32 (void)
{
- static BOOL is_9x = 0;
- OSVERSIONINFO os_ver;
- HMODULE ret;
- if (g_b_init_is_w9x == 0)
- {
- g_b_init_is_w9x = 1;
- ZeroMemory (&os_ver, sizeof (OSVERSIONINFO));
- os_ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- if (GetVersionEx (&os_ver))
- is_9x = (os_ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
- }
- if (is_9x)
- {
- ret = LoadLibrary ("Unicows.dll");
- if (!ret)
- {
- int button;
-
- button = MessageBox (NULL,
- "Emacs cannot load the UNICOWS.DLL library.\n"
- "This library is essential for using Emacs\n"
- "on this system. You need to install it.\n\n"
- "However, you can still use Emacs by invoking\n"
- "it with the '-nw' command-line option.\n\n"
- "Emacs will exit when you click OK.",
- "Emacs cannot load UNICOWS.DLL",
- MB_ICONERROR | MB_TASKMODAL
- | MB_SETFOREGROUND | MB_OK);
- switch (button)
- {
- case IDOK:
- default:
- exit (1);
- }
- }
- }
- else
- ret = LoadLibrary ("Gdi32.dll");
- return ret;
+ return maybe_load_unicows_dll ();
}
/* The following 3 functions call the problematic "wide" APIs via
lpvBuffer, lpmat2);
}
-static DWORD WINAPI get_char_width_32_w (HDC hdc, UINT uFirstChar,
- UINT uLastChar, LPINT lpBuffer)
+static DWORD WINAPI
+get_char_width_32_w (HDC hdc, UINT uFirstChar, UINT uLastChar, LPINT lpBuffer)
{
static GetCharWidth32W_Proc s_pfn_Get_Char_Width_32W = NULL;
HMODULE hm_unicows = NULL;
return s_pfn_Get_Char_Width_32W (hdc, uFirstChar, uLastChar, lpBuffer);
}
+#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 */
+
static int
memq_no_quit (Lisp_Object elt, Lisp_Object list)
{
intern_font_name (char * string)
{
Lisp_Object str = DECODE_SYSTEM (build_string (string));
- int len = SCHARS (str);
- Lisp_Object obarray = check_obarray (Vobarray);
- Lisp_Object tem = oblookup (obarray, SDATA (str), len, len);
- /* This code is similar to intern function from lread.c. */
- return SYMBOLP (tem) ? tem : Fintern (str, obarray);
+ return Fintern (str, obarray);
}
/* w32 implementation of get_cache for font backend.
= DECODE_SYSTEM (build_string (logfont.lfFaceName));
}
- font->frame = f;
font->max_width = w32_font->metrics.tmMaxCharWidth;
/* Parts of Emacs display assume that height = ascent + descent...
so height is defined later, after ascent and descent.
struct font_driver w32font_driver =
{
- 0, /* Qgdi */
+ LISP_INITIALLY_ZERO, /* Qgdi */
0, /* case insensitive */
w32font_get_cache,
w32font_list,
void
syms_of_w32font (void)
{
+#include "w32font.x"
+
DEFSYM (Qgdi, "gdi");
DEFSYM (Quniscribe, "uniscribe");
DEFSYM (QCformat, ":format");
DEFSYM (Qw32_charset_thai, "w32-charset-thai");
DEFSYM (Qw32_charset_mac, "w32-charset-mac");
- defsubr (&Sx_select_font);
-
w32font_driver.type = Qgdi;
register_font_driver (&w32font_driver, NULL);
}
void
globals_of_w32font (void)
{
- g_b_init_is_w9x = 0;
+#ifdef WINDOWSNT
g_b_init_get_outline_metrics_w = 0;
g_b_init_get_text_metrics_w = 0;
g_b_init_get_glyph_outline_w = 0;
g_b_init_get_char_width_32_w = 0;
+#endif
}